Arduino Nano ESP32 - DIYables Bluetooth App Joystick
Overview
This example implements an interactive 2D joystick control on the Arduino Nano ESP32 using BLE (Bluetooth Low Energy) via the DIYables Bluetooth STEM app. Receive real-time X/Y coordinates (-100 to +100) for directional control. Suitable for robot navigation, pan-tilt servos, motor control, and game controllers.
Note: The Arduino Nano ESP32 supports BLE only — Classic Bluetooth is not supported. The DIYables Bluetooth App works on both Android and iOS with BLE.

Features
- 2D Control: X and Y axes with range −100 to +100
- Configurable Sensitivity: Minimum movement threshold before triggering updates
- Auto-Return Option: Joystick can auto-center when released
- Real-Time Values: Continuous position updates while dragging
- Android & iOS Support: BLE is compatible with both platforms
- No Pairing Required: BLE connects without manual pairing
- Low Power: BLE consumes less power than Classic Bluetooth
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (30 sensors/displays) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Arduino Nano ESP32 Code
Detailed Instructions
- New to the Arduino Nano ESP32? Start with the Arduino Nano ESP32 getting started guide.
- Connect the Arduino Nano ESP32 to your computer via USB.
- Open Arduino IDE.
- Select the Arduino Nano ESP32 board and the correct COM port.
- Click the Libraries icon in the left sidebar.
- Search for "DIYables Bluetooth" and select the DIYables Bluetooth library by DIYables.
- Click Install.

- When prompted to install dependencies, click Install All.

BLE Code
- In Arduino IDE, open File Examples DIYables Bluetooth ArduinoBLE_Joystick, or paste the code into the editor.
- Click Upload to flash the sketch to the board.
- Open the Serial Monitor.
- The Serial Monitor output should look like:
Mobile App
Note: The DIYables Bluetooth App works on both Android and iOS with BLE. No manual pairing is required.
- Launch the DIYables Bluetooth App.
- On first launch, grant the following permissions:
- Nearby Devices (Android 12+) / Bluetooth (iOS) — required to scan and connect to Bluetooth devices
- Location (Android 11 and below only) — required by older Android versions to scan for BLE
- Ensure Bluetooth is enabled on your device.
- Tap Connect on the home screen. The app will scan for BLE devices.

- Tap "Arduino_Joystick" in the scan results.
- After connecting, return to the home screen and open the Joystick app.

Tap the settings icon on the home screen to show or hide apps. See the DIYables Bluetooth App User Manual for details.
- Drag the joystick in any direction.

Now look back at the Serial Monitor on Arduino IDE. You will see:
Creative Customization - Adapt the Code to Your Project
Handle Joystick Values
Configure Joystick Settings
Handle Config Request
Programming Examples
Differential Drive Robot
Pan-Tilt Servo
Direction with Dead Zone
Troubleshooting
Common Issues
1. Device not visible in the app
- Confirm the board is powered on and the sketch is uploaded
- Verify Bluetooth is enabled on your phone
- On Android 11 and below, enable Location services as well
2. Joystick not responding
- Check the Bluetooth connection status in the app
- Confirm the onJoystickValue callback is registered correctly
- Review the Serial Monitor for connection messages
3. Movement feels laggy
- Lower the sensitivity value for more frequent updates
- Ensure bluetoothServer.loop() runs without long delays
4. Values jump or are inconsistent
- Add a dead zone filter for small movements
- Review the sensitivity setting
5. Connection drops frequently
- Reduce distance to the Arduino
- Ensure a stable USB power supply
6. Upload fails or board not recognized
- Install the latest Arduino Nano ESP32 board package via Board Manager
- Try a different USB cable or port
Project Ideas
- Wireless robot controller
- Camera pan-tilt mount
- Robotic arm 2-axis control
- LED matrix position controller
- Game controller for Arduino games
Next Steps
After completing the Bluetooth Joystick example, explore:
- Bluetooth Slider — Linear value control
- Bluetooth Rotator — Angular control
- Bluetooth Monitor — Status feedback
- Multiple Bluetooth Apps — Combine joystick with other controls
Support
For additional help:
- Check the API Reference documentation
- Visit DIYables tutorials
- Arduino community forums