Community project

Bluetooth Joystick Controller

Photo of Bluetooth Joystick Controller
Generated with AI

ABEL FRANCIS SEQUIERA

Published December 5, 2026

Build a wireless gamepad controller that connects to computers, phones, and tablets via Bluetooth. This project combines an ESP32 microcontroller with a PS2 joystick module and nine tactile buttons to create a fully functional HID (Human Interface Device) that your operating system recognizes as a standard game controller.

This guide provides a complete parts list, wiring diagram showing all joystick and button connections to the ESP32, and ready-to-use firmware that handles Bluetooth pairing, analog stick calibration, and button input. Assembly takes under an hour and requires only basic soldering skills.

Wiring diagram

Wiring diagram for Bluetooth Joystick Controller
Loading diagram…

Gather all the parts

QtyComponent
1

PS2 Joystick Module (KY-023)

Two-axis analog thumb joystick module (KY-023 / PS2 style) with a push switch under the stick. Two 10 kOhm potentiometers give X and Y voltages that sit near half the supply at rest, and pressing the stick operates a digital switch. It runs from 3.3 to 5 V and connects through a five-pin GND, +5V, VRx, VRy, SW right-angle header.

1

12 mm Tactile Push Button (Round Cap)

Momentary 12 x 12 mm four-leg through-hole tactile push button with a round cap. Closes a normally open contact while pressed; wire diagonally opposite legs between a digital input configured with INPUT_PULLUP and GND.

1

12 mm Tactile Push Button (Round Cap)

Momentary 12 x 12 mm four-leg through-hole tactile push button with a round cap. Closes a normally open contact while pressed; wire diagonally opposite legs between a digital input configured with INPUT_PULLUP and GND.

1

12 mm Tactile Push Button (Round Cap)

Momentary 12 x 12 mm four-leg through-hole tactile push button with a round cap. Closes a normally open contact while pressed; wire diagonally opposite legs between a digital input configured with INPUT_PULLUP and GND.

1

12 mm Tactile Push Button (Round Cap)

Momentary 12 x 12 mm four-leg through-hole tactile push button with a round cap. Closes a normally open contact while pressed; wire diagonally opposite legs between a digital input configured with INPUT_PULLUP and GND.

1

12 mm Tactile Push Button (Round Cap)

Momentary 12 x 12 mm four-leg through-hole tactile push button with a round cap. Closes a normally open contact while pressed; wire diagonally opposite legs between a digital input configured with INPUT_PULLUP and GND.

1

12 mm Tactile Push Button (Round Cap)

Momentary 12 x 12 mm four-leg through-hole tactile push button with a round cap. Closes a normally open contact while pressed; wire diagonally opposite legs between a digital input configured with INPUT_PULLUP and GND.

1

12 mm Tactile Push Button (Round Cap)

Momentary 12 x 12 mm four-leg through-hole tactile push button with a round cap. Closes a normally open contact while pressed; wire diagonally opposite legs between a digital input configured with INPUT_PULLUP and GND.

1

12 mm Tactile Push Button (Round Cap)

Momentary 12 x 12 mm four-leg through-hole tactile push button with a round cap. Closes a normally open contact while pressed; wire diagonally opposite legs between a digital input configured with INPUT_PULLUP and GND.

1

12 mm Tactile Push Button (Round Cap)

Momentary 12 x 12 mm four-leg through-hole tactile push button with a round cap. Closes a normally open contact while pressed; wire diagonally opposite legs between a digital input configured with INPUT_PULLUP and GND.

Assemble it in 2 steps

1. Connect the joystick

With USB unplugged, connect GND to GND, VRX to GPIO32, VRY to GPIO33, and SW to GPIO27. Connect the joystick pin labeled +5V to the ESP32's 3V3 pin.

  • Do not power the joystick from 5 V. Its outputs could damage the ESP32 inputs.

2. Connect nine push buttons

With USB unplugged, place each button across a breadboard center gap. For buttons 1 through 9, connect one leg to GPIO25, GPIO4, GPIO13, GPIO14, GPIO16, GPIO17, GPIO18, GPIO19, and GPIO21, respectively. Connect each diagonally opposite leg to a ground rail linked to ESP32 GND. The stick click is button 10.

Review all connections

1. Connections between "stick" and "ESP32"

FunctionstickESP32
power+5V3V3
groundGNDGND
analogVRXGPIO 32
analogVRYGPIO 33
digitalSWGPIO 27

2. Connections between "fire" and "ESP32"

FunctionfireESP32
digitalSIGNALGPIO 25
groundGNDGND

3. Connections between "button2" and "ESP32"

Functionbutton2ESP32
digitalSIGNALGPIO 4
groundGNDGND

4. Connections between "button3" and "ESP32"

Functionbutton3ESP32
digitalSIGNALGPIO 13
groundGNDGND

5. Connections between "button4" and "ESP32"

Functionbutton4ESP32
digitalSIGNALGPIO 14
groundGNDGND

6. Connections between "button5" and "ESP32"

Functionbutton5ESP32
digitalSIGNALGPIO 16
groundGNDGND

7. Connections between "button6" and "ESP32"

Functionbutton6ESP32
digitalSIGNALGPIO 17
groundGNDGND

8. Connections between "button7" and "ESP32"

Functionbutton7ESP32
digitalSIGNALGPIO 18
groundGNDGND

9. Connections between "button8" and "ESP32"

Functionbutton8ESP32
digitalSIGNALGPIO 19
groundGNDGND

10. Connections between "button9" and "ESP32"

Functionbutton9ESP32
digitalSIGNALGPIO 21
groundGNDGND

Deploy the firmware

#include <Arduino.h>
#include <BLEDevice.h>
#include <BLEHIDDevice.h>
#include <BLESecurity.h>

constexpr int X=32, Y=33, CLICK=27;
constexpr int buttonsPins[]={25,4,13,14,16,17,18,19,21,CLICK};
uint8_t mapData[]={0x05,1,0x09,5,0xA1,1,0x85,1,
  0x09,0x30,0x09,0x31,0x15,0x81,0x25,0x7f,0x75,8,0x95,2,0x81,2,
  0x05,9,0x19,1,0x29,10,0x15,0,0x25,1,0x75,1,0x95,10,0x81,2,
  0x75,6,0x95,1,0x81,3,0xC0};
BLEServer* server;
BLECharacteristic* input;
int cx,cy;
int average(int pin){int sum=0; for(int i=0;i<16;i++) sum+=analogRead(pin); return sum/16;}
int axis(int raw,int center){
  int d=raw-center;
  if(abs(d)<100) return 0;
  int span=d<0?center:4095-center;
  return constrain(d*155/max(span,1),-127,127);
}
void setup(){
  for(int pin : buttonsPins) pinMode(pin,INPUT_PULLUP);
  delay(250); cx=average(X); cy=average(Y);
  BLEDevice::init("ESP32 Thumb Gamepad");
  server=BLEDevice::createServer();
  auto hid=new BLEHIDDevice(server);
  input=hid->inputReport(1);
  hid->manufacturer()->setValue("DIY");
  hid->pnp(2,0x303A,1,1); hid->hidInfo(0,1);
  auto security=new BLESecurity();
  security->setAuthenticationMode(ESP_LE_AUTH_BOND);
  security->setCapability(ESP_IO_CAP_NONE);
  hid->reportMap(mapData,sizeof(mapData)); hid->startServices();
  hid->setBatteryLevel(100);
  auto adv=server->getAdvertising();
  adv->setAppearance(0x03C4); adv->addServiceUUID(hid->hidService()->getUUID()); adv->start();
}
void loop(){
  static bool wasConnected=false;
  static uint16_t lastButtons=0, stable=0;
  static uint32_t changed=0;
  bool connected=server->getConnectedCount()>0;
  if(wasConnected && !connected) server->startAdvertising();
  wasConnected=connected;
  uint16_t buttons=0;
  for(unsigned i=0;i<sizeof(buttonsPins)/sizeof(buttonsPins[0]);++i)
    if(digitalRead(buttonsPins[i])==LOW) buttons |= 1u<<i;
  if(buttons!=lastButtons){lastButtons=buttons; changed=millis();}
  if(millis()-changed>=20) stable=buttons;
  if(connected){
    uint8_t report[]={uint8_t(axis(average(X),cx)),uint8_t(axis(average(Y),cy)),uint8_t(stable),uint8_t(stable>>8)};
    input->setValue(report,sizeof(report)); input->notify();
  }
  delay(15);
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik