Arduino MKR WiFi 1010 - DIYables Bluetooth App Joystick

Overview

In this tutorial, we are going to learn how to use the Bluetooth Joystick feature with the Arduino MKR WiFi 1010. The Arduino MKR WiFi 1010's built-in BLE support and MKR form factor make it a solid choice for wireless robotics and remote-control projects. The app shows a virtual joystick on your phone screen, and when you move it, the X and Y coordinates (−100 to +100) are sent to your Arduino over BLE in real time — perfect for driving a robot, controlling a two-axis mechanism, or steering any project that needs live directional input from your phone.

Note: The Arduino MKR WiFi 1010 only supports BLE (Bluetooth Low Energy) for this library. It does not use Classic Bluetooth with this library. The DIYables Bluetooth App supports both BLE and Classic Bluetooth on Android, and BLE on iOS. Since this board uses BLE, the app works on both Android and iOS.

Arduino MKR WiFi 1010 Bluetooth Joystick Example - 2D Directional Control via BLE Tutorial

Features

  • 2D Control: X and Y axes with range -100 to +100
  • Configurable Sensitivity: Minimum movement threshold to trigger updates
  • Auto-Return Option: Joystick can auto-center when released
  • Real-Time Values: Continuous position updates while dragging
  • Works on Android & iOS: BLE is supported on both platforms
  • No Pairing Required: BLE auto-connects without manual pairing
  • Low Power: BLE consumes less power than Classic Bluetooth

Hardware Preparation

1×Arduino MKR WiFi 1010
1×Micro USB Cable
1×Breadboard
1×Jumper Wires

Or you can buy the following kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Arduino MKR WiFi 1010 Code

Detailed Instructions

Follow these instructions step by step:

  • If this is your first time using the Arduino MKR WiFi 1010, refer to the Arduino MKR WiFi 1010 getting started guide.
  • Connect the Arduino MKR WiFi 1010 board to your computer using a Micro USB cable.
  • Launch the Arduino IDE on your computer.
  • Select Arduino MKR WiFi 1010 board and the appropriate COM port.
  • Navigate to the Libraries icon on the left bar of the Arduino IDE.
  • Search "DIYables Bluetooth", then find the DIYables Bluetooth library by DIYables
  • Click Install button to install the library.
Arduino MKR WiFi 1010 DIYables Bluetooth library
  • You will be asked for installing some other library dependencies
  • Click Install All button to install all library dependencies.
Arduino MKR WiFi 1010 DIYables Bluetooth dependency

BLE Code

  • On Arduino IDE, Go to File Examples DIYables Bluetooth ArduinoBLE_Joystick example, or copy the above code and paste it to the editor of Arduino IDE
/* * DIYables Bluetooth Library - Bluetooth Joystick Example * Works with DIYables Bluetooth STEM app on Android and iOS * * This example demonstrates the Bluetooth Joystick feature: * - Interactive joystick control via Bluetooth * - Real-time X/Y coordinate values (-100 to +100) * - Control pins based on joystick position * * Compatible Boards: * - Arduino UNO R4 WiFi * - Arduino Nano 33 BLE / BLE Sense * - Arduino Nano 33 IoT * - Arduino MKR WiFi 1010 * - Arduino Nano RP2040 Connect * - Any board supporting the ArduinoBLE library * * Setup: * 1. Upload the sketch to your Arduino * 2. Open Serial Monitor to see connection status * 3. Use DIYables Bluetooth App to connect and control the joystick * * Tutorial: https://diyables.io/bluetooth-app * Author: DIYables */ #include <DIYables_BluetoothServer.h> #include <DIYables_BluetoothJoystick.h> #include <platforms/DIYables_ArduinoBLE.h> // BLE Configuration const char* DEVICE_NAME = "Arduino_Joystick"; const char* SERVICE_UUID = "19B10000-E8F2-537E-4F6C-D104768A1214"; const char* TX_UUID = "19B10001-E8F2-537E-4F6C-D104768A1214"; const char* RX_UUID = "19B10002-E8F2-537E-4F6C-D104768A1214"; // Create Bluetooth instances DIYables_ArduinoBLE bluetooth(DEVICE_NAME, SERVICE_UUID, TX_UUID, RX_UUID); DIYables_BluetoothServer bluetoothServer(bluetooth); // Create Joystick app instance // Configure with autoReturn=false and sensitivity=5 (minimum 5% change to trigger updates) DIYables_BluetoothJoystick bluetoothJoystick(false, 5); // Variables to store current joystick values int currentJoystickX = 0; int currentJoystickY = 0; void setup() { Serial.begin(9600); while (!Serial); Serial.println("DIYables Bluetooth - Joystick Example"); // TODO: initialize your hardware pins here // Initialize Bluetooth server with platform-specific implementation bluetoothServer.begin(); // Add joystick app to server bluetoothServer.addApp(&bluetoothJoystick); // Set up connection event callbacks bluetoothServer.setOnConnected([]() { Serial.println("Bluetooth connected!"); }); bluetoothServer.setOnDisconnected([]() { Serial.println("Bluetooth disconnected!"); }); // Set up joystick callback for position changes bluetoothJoystick.onJoystickValue([](int x, int y) { // Store the received values currentJoystickX = x; currentJoystickY = y; // Print joystick position values (-100 to +100) Serial.print("Joystick - X: "); Serial.print(x); Serial.print(", Y: "); Serial.println(y); // TODO: Add your control logic here based on joystick position // Examples: // - Control motors: if (x > 50) { /* move right */ } // - Control servos: servo.write(map(y, -100, 100, 0, 180)); // - Control LEDs: analogWrite(LED_PIN, map(abs(x), 0, 100, 0, 255)); // - Send commands to other devices via Serial, I2C, SPI, etc. }); // Optional: Handle requests for current joystick values (when app loads) bluetoothJoystick.onGetConfig([]() { // Send the stored joystick values back to the app bluetoothJoystick.send(currentJoystickX, currentJoystickY); Serial.print("App requested values - Sent: X="); Serial.print(currentJoystickX); Serial.print(", Y="); Serial.println(currentJoystickY); }); // You can change configuration at runtime: // bluetoothJoystick.setAutoReturn(false); // Disable auto-return // bluetoothJoystick.setSensitivity(10.0); // Only send updates when joystick moves >10% (less sensitive) Serial.println("Waiting for Bluetooth connection..."); } void loop() { // Handle Bluetooth server communications bluetoothServer.loop(); // TODO: Add your main application code here delay(10); }
  • Click Upload button on Arduino IDE to upload code to Arduino MKR WiFi 1010
  • Open the Serial Monitor
  • Check out the result on Serial Monitor. It looks like the below:
COM6
Send
DIYables Bluetooth - Joystick Example Waiting for Bluetooth connection...
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Mobile App

  • Install the DIYables Bluetooth App on your smartphone: Android | iOS

Note: The DIYables Bluetooth App supports both BLE and Classic Bluetooth on Android, and BLE on iOS. Since the Arduino MKR WiFi 1010 uses BLE, the app works on both Android and iOS. No manual pairing is needed for BLE — just scan and connect.

  • Open the DIYables Bluetooth App
  • When opening the app for the first time, it will ask for permissions. Please grant the following:
    • Nearby Devices permission (Android 12+) / Bluetooth permission (iOS) - required to scan and connect to Bluetooth devices
    • Location permission (Android 11 and below only) - required by older Android versions to scan for BLE devices
  • Make sure Bluetooth is turned on on your phone
  • On the home screen, tap the Connect button. The app will scan for BLE devices.
DIYables Bluetooth App - Home Screen with Scan Button
  • Find and tap "Arduino_Joystick" in the scan results to connect.
  • Once connected, the app automatically goes back to the home screen. Select the Joystick app from the app menu.
DIYables Bluetooth App - Home Screen with Joystick App

Note: You can tap the settings icon on the home screen to hide/show apps on the home screen. For more details, see the DIYables Bluetooth App User Manual.

  • Drag the joystick in any direction
DIYables Bluetooth App - Joystick Screen

Now look back at the Serial Monitor on Arduino IDE. You will see:

COM6
Send
Bluetooth connected! Joystick - X: 50, Y: 0 Joystick - X: 100, Y: 50 Joystick - X: 0, Y: -75 Joystick - X: 0, Y: 0
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Creative Customization - Adapt the Code to Your Project

Handle Joystick Values

bluetoothJoystick.onJoystickValue([](int x, int y) { currentJoystickX = x; currentJoystickY = y; Serial.print("Joystick - X: "); Serial.print(x); Serial.print(", Y: "); Serial.println(y); // TODO: Add your control logic here });

Configure Joystick Settings

// Constructor: DIYables_BluetoothJoystick(autoReturn, sensitivity) DIYables_BluetoothJoystick bluetoothJoystick(false, 5); // Change settings at runtime bluetoothJoystick.setAutoReturn(true); // Auto-center when released bluetoothJoystick.setSensitivity(10.0); // Only update when moved >10%

Handle Config Request

bluetoothJoystick.onGetConfig([]() { bluetoothJoystick.send(currentJoystickX, currentJoystickY); });

Programming Examples

Differential Drive Robot

const int LEFT_MOTOR_PIN = 9; const int RIGHT_MOTOR_PIN = 10; const int LEFT_DIR_PIN = 7; const int RIGHT_DIR_PIN = 8; bluetoothJoystick.onJoystickValue([](int x, int y) { // Differential drive: mix X and Y int leftSpeed = constrain(y + x, -100, 100); int rightSpeed = constrain(y - x, -100, 100); // Set direction digitalWrite(LEFT_DIR_PIN, leftSpeed >= 0 ? HIGH : LOW); digitalWrite(RIGHT_DIR_PIN, rightSpeed >= 0 ? HIGH : LOW); // Set speed (PWM) analogWrite(LEFT_MOTOR_PIN, map(abs(leftSpeed), 0, 100, 0, 255)); analogWrite(RIGHT_MOTOR_PIN, map(abs(rightSpeed), 0, 100, 0, 255)); });

Pan-Tilt Servo

#include <Servo.h> Servo panServo, tiltServo; void setup() { panServo.attach(9); tiltServo.attach(10); bluetoothJoystick.onJoystickValue([](int x, int y) { int panAngle = map(x, -100, 100, 0, 180); int tiltAngle = map(y, -100, 100, 0, 180); panServo.write(panAngle); tiltServo.write(tiltAngle); }); }

Direction with Dead Zone

const int DEAD_ZONE = 15; bluetoothJoystick.onJoystickValue([](int x, int y) { if (abs(x) < DEAD_ZONE && abs(y) < DEAD_ZONE) { Serial.println("STOPPED"); return; } if (abs(y) > abs(x)) { Serial.println(y > 0 ? "FORWARD" : "BACKWARD"); } else { Serial.println(x > 0 ? "RIGHT" : "LEFT"); } });

Troubleshooting

Common Issues

1. Cannot find the device in the app

  • Make sure the Arduino MKR WiFi 1010 is powered on and the sketch is uploaded
  • Ensure your phone's Bluetooth is enabled
  • On Android 11 and below, also enable Location services

2. Joystick not responding

  • Check Bluetooth connection status in the app
  • Verify the onJoystickValue callback is set up correctly
  • Check Serial Monitor for connection messages

3. Movement feels laggy

  • Reduce sensitivity value for more frequent updates
  • Ensure bluetoothServer.loop() is called without long delays

4. Values jump or are inconsistent

  • Add a dead zone filter for small movements
  • Check sensitivity setting

5. Connection drops frequently

  • Move closer to the Arduino (reduce distance)
  • Ensure stable USB power supply

6. Upload fails or board not recognized

  • Install the latest Arduino SAMD Boards package via Boards Manager (≥ 1.8.13)
  • 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 mastering the Bluetooth Joystick example, try:

  1. Bluetooth Slider - For linear value control
  2. Bluetooth Rotator - For angular control
  3. Bluetooth Monitor - For status feedback
  4. Multiple Bluetooth Apps - Combining joystick with other controls

Support

For additional help:

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!