In this project, I will show you how to implement a Bluetooth Controlled Servo Motor using Arduino. Using this project, you can control a servo motor like TowerPro SG90 or MG90S with the help of an App in an Android Smartphone over Bluetooth connection.
I have used servo motors in several projects like the DIY Arduino & Bluetooth Robotic Arm, Web Controlled Servo using ESP8266, Arduino Joystick Interface to name a few. In fact, servo motors are one of the important components is projects where precise positioning is required.
In this project, as mentioned earlier, I will show you how to control a Servo Motor using Bluetooth. But before proceeding further into the details of Bluetooth Controlled Servo Motor using Arduino, there are a few important things to know like how a servo motor works and how can you control the position of the servo motor.
A Brief Note on Servo Motor and its Control
Servo Motors are basically DC Motors with additional circuitry that aid in achieving accurate positioning of the servo motor. In order to control the rotation of the servo motor’s shaft, you need a special signal called Pulse Width Modulation or PWM signal.
Based on the width of the pulse, the position of the servo motor varies. There are several ways in which you can generate the PWM Signal to control a Servo Motor. The traditional way is to use fully analog circuits like the 555 Timer IC and using a potentiometer to control the width of the pulse.
But with the help of microcontrollers like Arduino (ATmega328 to be precise), you can generate PWM Signals without any external components.
NOTE: If you want to test whether your Servo Motor is working or not, you can implement a simple design similar to the one I have used in the How to make a Simple Servo Motor Tester Circuit, where you don’t need any microcontrollers and programming to test the servo motor.
Concept of Bluetooth Controlled Servo Motor using Arduino
The main concept of the Bluetooth Controlled Servo Motor using Arduino project is very simple. Control the Servo Motor using PWM Signals generated by Arduino. The inputs to the Arduino are given from an Android Smart Phone over Bluetooth Communication.
The circuit diagram of the project Bluetooth Controlled Servo Motor using Arduino is given below.
- Arduino UNO
- HC-05 Bluetooth Module
- TowerPro SG90 Servo Motor
- Connecting Wires
- 5V Power Supply
The design of the circuit for controlling a Servo Motor using Arduino and Bluetooth is very easy. Connect the Control Pin of the Servo Motor to Pin 11 of Arduino. It is important that you connect the control pin to a PWM enabled pin of Arduino.
I will be using a Software Serial option of Arduino and hence Pins 2 and 3 of Arduino are fixed as RX and TX. So, connect the TX of the Bluetooth Module to RX (Pin 2) of Arduino.
Since the job of Bluetooth Module is to transfer data received from Phone and transmit it to Arduino, I have used only its TX Pin.
For more information on HC-05 Bluetooth Module and how to interface it with Arduino, please refer “Arduino HC-05 Bluetooth Module”.
Servo Motor Control App
I have used an App called “Servo Motor Kontrol” developed by “YSRGGS”. The layout of the app after connecting it to the Bluetooth Module is shown below.
As you can see, the app provides two ways in which you can control the servo motor: using dedicated buttons or using the slider.
To download this app, visit this link: “Servo Motor Kontrol”.
The code for the project Bluetooth Controlled Servo Motor using Arduino is given below.
|SoftwareSerial mySerial(2, 3); // RX, TX
|int Position ;
|Position = mySerial.read();
|Position = map(Position, 0, 180, 180, 0);
The working of this project is very simple. Make the connections as per the circuit diagram and upload the code to Arduino. Then open the Servo Motor Kontrol App (assuming it is already installed in your Android Phone) and connect to the Bluetooth Module.
Once the connection is successful, you can control the servo motor either by adjusting the slider or by pressing any of the preset buttons.
A simple way to control your servo motor is demonstrated in this project. Using this project, you can control any servo motor using Arduino and a Bluetooth Module.
If you are a beginner, this project can be a beginning step towards implementing several complex Robotic Projects involving Servo Motors.