Arduino Nano Control Servo Motor via Bluetooth

This tutorial instructs you how to program an Arduino Nano to manage a Servo Motor using either Bluetooth (HC-05 module) or BLE (HM-10 module). Instructions for both modules will be provided.

We will use the Bluetooth Serial Monitor App on a smartphone to transmit the angle value to Arduino Nano. Arduino Nano will adjust the servo motor in accordance with the received value.

Arduino Nano Servo Motor Bluetooth

Hardware Preparation

1×Arduino Nano
1×USB A to Mini-B USB cable
1×HC-05 Bluetooth Module
1×(Alternative) HM-10 BLE Module
1×Servo Motor
1×Jumper Wires
1×(Optional) 9V Power Adapter for Arduino Nano
1×(Recommended) Screw Terminal Adapter for Arduino Nano

Or you can buy the following sensor 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. We appreciate your support.

Overview of Servo Motor and Bluetooth Module

If you are not familiar with Servo Motors, Bluetooth Modules, their pinouts, how they work, and how to program them, please refer to the following tutorials for more information:

Wiring Diagram

  • To manage a Servo Motor with Classic Bluetooth, the HC-05 Bluetooth module should be used and the wiring diagram provided should be consulted.
The wiring diagram between Arduino Nano and Servo Motor Bluetooth

This image is created using Fritzing. Click to enlarge image

  • To operate a Servo Motor with BLE, the HM-10 BLE module should be used. The wiring diagram for this is given below.
The wiring diagram between Arduino Nano and Servo Motor BLE

This image is created using Fritzing. Click to enlarge image

Arduino Nano Code - controls Servo Motor via Bluetooth/BLE

The code given here is able to be used with both the HC-10 Bluetooth module and the HM-10 BLE module.

/* * This Arduino Nano code was developed by * * This Arduino Nano code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * */ #include <Servo.h> #include <SoftwareSerial.h> #define SOFT_RX 4 // The Arduino Nano pin connected to the TX of the bluetooth module #define SOFT_TX 5 // The Arduino Nano pin connected to the RX of the bluetooth module #define SERVO_PIN 12 // The Arduino Nano pin connected to the servo motor SoftwareSerial bluetooth(SOFT_RX, SOFT_TX); Servo servo; // create servo object to control a servo int pos = 0; // variable to store the servo position void setup() { Serial.begin(9600); bluetooth.begin(9600); servo.attach(SERVO_PIN); } void loop() { if (bluetooth.available()) { // if there is data comming int angle = bluetooth.parseInt(); if (angle >= 0 && angle <= 180) { servo.write(angle); // rotate servo bluetooth.print("Rotated servo to angle: ");// reports action to smartphone app bluetooth.println(angle); } else { bluetooth.print("Invalid angle: ");// reports invalid value to smartphone app bluetooth.println(angle); } } }

Detailed Instructions

  • Install Bluetooth Serial Monitor App on your smartphone.
  • Take the code given and open it in the Arduino IDE, then upload it to your Arduino Nano board.
  • In case you have difficulty uploading the code, try disconnecting the TX and RX pins from the Bluetooth module, then upload the code, and afterwards reconnect the RX/TX pins.
  • Open the Bluetooth Serial Monitor App on your smartphone and choose either Classic Bluetooth or BLE, depending on the module you are using.
Bluetooth Serial Monitor App
  • Connect the app to the HC-05 Bluetooth module or HM-10 BLE module.
Bluetooth Serial Monitor pairing
  • Enter an angle such as 45 or 90 and press the Send button.
Bluetooth Serial Monitor App
  • Witness the Servo Motor's angle alteration.
  • Examine the outcomes on the Android App.
Bluetooth Serial Monitor App

If you find the Bluetooth Serial Monitor app helpful, please rate it 5 stars on Play Store. Thank you for your support!

Video Tutorial

Function References


  • 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!