Arduino Nano 33 IoT - DIYables Bluetooth App Rotator

Overview

In this tutorial, we are going to learn how to use the Bluetooth Rotator feature with the Arduino Nano 33 IoT. The rotator widget on the app looks like a dial that you can turn with your finger, and the angle value is sent to your Arduino over BLE. You can set a limited range (e.g. 0–180°) for servo control, or use continuous rotation mode for motors and camera rigs. The Nano 33 IoT's compact size makes it easy to build into servo-driven mechanisms.

Note: The Arduino Nano 33 IoT only supports BLE (Bluetooth Low Energy). It does not support Classic Bluetooth. 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 Nano 33 IoT Bluetooth Rotator Example - Angle Control via BLE Tutorial

Features

  • Limited Mode: Set min/max angle range (e.g., 0° to 180°)
  • Continuous Mode: Full 360° continuous rotation
  • Real-Time Angle: Receive angle updates as user rotates
  • Servo Integration: Direct servo motor control
  • Initial Angle Sync: Send current position on connect
  • Works on Android & iOS: BLE is supported on both platforms
  • No Pairing Required: BLE auto-connects without manual pairing

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×(optional) Servo Motor
1×Breadboard
1×Jumper Wires
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

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 .

Buy Note: For controlling multiple servo motors, use the PCA9685 16 Channel PWM Servo Driver Module to save MCU pins and simplify wiring.

Arduino Nano 33 IoT Code

Detailed Instructions

Follow these instructions step by step:

  • If this is your first time using the Arduino Nano 33 IoT, refer to the Arduino Nano 33 IoT getting started guide.
  • Connect the Arduino Nano 33 IoT board to your computer using a Micro USB cable.
  • Launch the Arduino IDE on your computer.
  • Select Arduino Nano 33 IoT 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 Nano 33 IoT DIYables Bluetooth library
  • You will be asked for installing some other library dependencies
  • Click Install All button to install all library dependencies.
Arduino Nano 33 IoT DIYables Bluetooth dependency

BLE Code

  • On Arduino IDE, Go to File Examples DIYables Bluetooth ArduinoBLE_Rotator example, or copy the above code and paste it to the editor of Arduino IDE
/* * DIYables Bluetooth Library - Bluetooth Rotator Example * Works with DIYables Bluetooth STEM app on Android and iOS * * This example demonstrates the Bluetooth Rotator feature: * - Rotatable disc/knob control (0-360 degrees) * - Continuous or limited angle range * - Perfect for servo control, compass display, volume knobs * * 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 * * Optional: Servo motor for visual feedback * * Setup: * 1. Upload the sketch to your Arduino * 2. Open Serial Monitor to see connection status * 3. Use DIYables Bluetooth App to connect and rotate the knob * * Tutorial: https://diyables.io/bluetooth-app * Author: DIYables */ #include <DIYables_BluetoothServer.h> #include <DIYables_BluetoothRotator.h> #include <platforms/DIYables_ArduinoBLE.h> // BLE Configuration const char* DEVICE_NAME = "Arduino_Rotator"; 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 Rotator app instance // Option 1: Continuous mode (0-360, wraps around) // DIYables_BluetoothRotator bluetoothRotator(ROTATOR_MODE_CONTINUOUS); // Option 2: Limited mode (constrained angle range) DIYables_BluetoothRotator bluetoothRotator(ROTATOR_MODE_LIMITED, 0, 180); // Variables to store current angle float currentAngle = 0.0; // Optional: Servo control (uncomment if using Servo library) // #include <Servo.h> // Servo myServo; // const int SERVO_PIN = 9; void setup() { Serial.begin(9600); while (!Serial); Serial.println("DIYables Bluetooth - Rotator Example"); // Optional: Initialize servo // myServo.attach(SERVO_PIN); // myServo.write(0); bluetoothServer.begin(); bluetoothServer.addApp(&bluetoothRotator); bluetoothServer.setOnConnected([]() { Serial.println("Bluetooth connected!"); bluetoothRotator.send(currentAngle); }); bluetoothServer.setOnDisconnected([]() { Serial.println("Bluetooth disconnected!"); }); bluetoothRotator.onRotatorAngle([](float angle) { currentAngle = angle; Serial.print("Rotator angle: "); Serial.print(angle); Serial.println("°"); // TODO: Add your control logic here based on angle // Examples: // - Servo control: servo.write(map(angle, 0, 360, 0, 180)); // - Stepper motor: stepper.moveTo(angleToSteps(angle)); // - LED ring: setLEDPosition(angle); // - Volume control: setVolume(map(angle, 0, 360, 0, 100)); }); Serial.println("Waiting for Bluetooth connection..."); } void loop() { bluetoothServer.loop(); delay(10); }
  • Click Upload button on Arduino IDE to upload code to Arduino Nano 33 IoT
  • Open the Serial Monitor
  • Check out the result on Serial Monitor. It looks like the below:
COM6
Send
DIYables Bluetooth - Rotator 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 Nano 33 IoT 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_Rotator" in the scan results to connect.
  • If not found, please update the firmware for the Bluetooth module following this guide on How to Upgrade the Firmware on Arduino Nano 33 IoT
  • Once connected, the app automatically goes back to the home screen. Select the Rotator app from the app menu.
DIYables Bluetooth App - Home Screen with Rotator 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.

  • You will see a rotary dial showing 0° to 180°
  • Rotate the dial to send angle values to the Arduino
DIYables Bluetooth App - Rotator Screen

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

COM6
Send
Bluetooth connected! Angle changed: 45.00° Angle changed: 90.00° Angle changed: 135.00°
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Creative Customization - Adapt the Code to Your Project

Rotation Modes

// Limited mode: specify min and max angle DIYables_BluetoothRotator bluetoothRotator(bluetoothServer, ROTATOR_MODE_LIMITED, 0, 180); // Continuous mode: full 360° rotation DIYables_BluetoothRotator bluetoothRotator(bluetoothServer, ROTATOR_MODE_CONTINUOUS);

Handle Angle Changes

bluetoothRotator.onRotatorAngle([](float angle) { Serial.print("Angle: "); Serial.println(angle); // Control a servo motor myServo.write((int)angle); });

Send Current Angle

// Send current angle to the app (e.g., on connect) bluetoothRotator.sendAngle(currentAngle);

Programming Examples

Servo Motor Control

#include <Servo.h> Servo myServo; float currentAngle = 90; void setup() { myServo.attach(9); myServo.write(currentAngle); bluetoothRotator.onRotatorAngle([](float angle) { currentAngle = angle; myServo.write((int)angle); Serial.print("Servo: "); Serial.println(angle); }); } void loop() { bluetoothServer.loop(); }

Pan-Tilt Camera Mount

Servo panServo; Servo tiltServo; // Use two rotator instances for pan and tilt // Or use a single rotator for one axis // and a slider for the other void setup() { panServo.attach(9); tiltServo.attach(10); bluetoothRotator.onRotatorAngle([](float angle) { panServo.write((int)angle); Serial.print("Pan: "); Serial.println(angle); }); }

Troubleshooting

Common Issues

1. Cannot find the device in the app

  • Make sure the Arduino Nano 33 IoT 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. Servo not responding

  • Verify the servo is wired to the correct pin
  • Check that the servo library is included and attach() is called
  • Ensure adequate power supply for the servo

3. Angle range seems wrong

  • Check the min/max values in the constructor
  • Make sure you're using ROTATOR_MODE_LIMITED for bounded range

4. Dial resets to 0 on reconnect

  • Send the current angle using sendAngle() when the device reconnects
  • The example code handles this in the onRotatorAngle callback

5. 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

  • Servo motor controller
  • Pan-tilt camera mount
  • Robotic arm joint control
  • Dial-based thermostat control
  • Compass/heading display

Next Steps

After mastering the Bluetooth Rotator example, try:

  1. Bluetooth Slider - For linear value control
  2. Bluetooth Joystick - For 2D position control
  3. Bluetooth Analog Gauge - For visual feedback
  4. Multiple Bluetooth Apps - Combining rotator with other apps

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!