Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based BLE Joystick with Potentiometer Control and LED Indicator

View and Edit Project In Cirkit DesignerImage of ESP32-Based BLE Joystick with Potentiometer Control and LED Indicator

Circuit Documentation

Summary

This circuit is designed to interface an ESP32 microcontroller with a rotary potentiometer, a pushbutton, an LED, and a resistor. The ESP32 is powered by a 5V battery and communicates via Bluetooth to act as a joystick. The potentiometer is used to control the joystick's X-axis, while the pushbutton can be used for additional input. The LED is connected through a resistor to indicate the status of the circuit.

Component List

  1. 5V Battery

    • Description: Power source for the circuit.
    • Pins: Positive, Negative
  2. ESP32 38 PINS

    • Description: Microcontroller with Bluetooth capabilities.
    • Pins: GND, 23, 22/SCL, 1, 2, 21/SDA, 19, 18, 5, 17/TX2, 16/RX2, 4, 0, 15, D1, D0, CLK, 3V3, EN, VP, VN, 34, 35, 32, 33, 25, 26, 27, 14, 12, 13, D2, D3, 11, 5V/VIN
  3. PR-Rotary Potentiometer

    • Description: Variable resistor used to control the joystick's X-axis.
    • Pins: GND, OUT, VCC
  4. LED: Two Pin (red)

    • Description: Indicator LED.
    • Pins: Cathode, Anode
  5. Resistor

    • Description: Limits current to the LED.
    • Pins: Pin1, Pin2
    • Properties:
      • Resistance: 200 Ohms
  6. Pushbutton

    • Description: User input button.
    • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)

Wiring Details

5V Battery

ESP32 38 PINS

PR-Rotary Potentiometer

LED: Two Pin (red)

Resistor

Pushbutton

Code Documentation

Code for ESP32 Microcontroller

#include <BleGamepad.h>

BleGamepad bleGamepad("ESP32 Joystick", "ESP32 Dev Kit", 100); // Device name and information

const int potPin = 25; // ADC pin for potentiometer

void setup() {
  Serial.begin(9600);
  Serial.println("Starting BLE Joystick...");
  
  // Initialize BLE joystick
  bleGamepad.begin();
}

void loop() {
  if (bleGamepad.isConnected()) {
    // Read potentiometer value
    int rawValue = analogRead(potPin);

    // Map value to joystick range (-32767 to 32767)
    int joystickValue = map(rawValue, 0, 4095, -32767, 32767);

    // Send X-axis value
    bleGamepad.setAxes(joystickValue, 0, 0, 0, 0, 0); // Set X-axis, other axes 0

    // Small delay for transmission stability
    delay(10);
  }
}

Code File Information