In this project you are going to learn how to control a servo motor to rotate from 0 to 180 degree precisely, using the Android Smart Phone App. Servos are known for their precise angle rotations and is widely used in robotic applications. So, this tutorial is a great project to start with.
1. Arduino IDE
THEORY & FUNDAMENTAL
In the App, there is a slider controller that has a minimum value of “0” and maximum value of “180”. The Android App sends packet data to CT UNO through serial communication of Bluetooth. Please note that the data is in ASCII string.
The slider is the servo controller. For example if the slider is at “90”, the servo pointer will be at angle 90 degree as well.
When the packet data is received, CT UNO converts the ASCII string into integer. Based on the integer, it generates pulse PWM or duty cycle to the servo.
In this tutorial the PWM’s min pulse is 620 ms while the maximum is 2500 ms.
1. Plug and connect all electronics as shown in the circuit diagram.
2. Take note the signal is at Pin 8, jumper Tx at D1 and jumper Rx is at D0.
3. Open up Arduino IDE and compile or upload the program to the CT UNO.
4. Set up the App in the Smartphone. (Watch the video)
The code should be easily understood with the help of the comments on each line. If the libraries “Servo.h” and “SoftwareSerial.h” in the code are shown in orange color, that mean you don’t have it yet. Go and download and import it into Arduino IDE.
A few highlights of the code:
1. Calibrate the Duty Cycle range of your servo to get precise servo rotation.
2. Don’t change the Baudrate of 9600 because it is standard Baudrate for Bluetooth.
3. SoftwareSerial library allows you to transfer and receive data through serial communication.
4. Speed of servo is fixed. Use this library instead of “Servo.h” library if you want the speed varies
5. parseInt() returns the first valid (long) integer number from the serial buffer. Characters that are not integers (or the minus sign) are skipped. For Example, if you send data “90K”, it captures as “90” not as “9” “0” “K” or “90K”.
Android App Setting and Video Example
1. The password to pair the Bluetooth is 1234
2. Please power up the servo through a different power source if the servo shows jittery performance as it means there is not enough current to power the motor.