Control Servo angle with BT
In this Arduino Tutorial we will show you how you can control Servo angle with BT (Bluetooth) using the Arduino Board and the Processing Development Environment. You can watch the following video or read the written tutorial below for more details.
Overview
All you need for this Arduino Tutorial is an Servo Motor for angular motion, Bluetooth Module, Jumper Wire to connect Servo Motor, Bluetooth Module and an Arduino Board for controlling servo and receive command through BT.
About Servo Motor & Bluetooth Module
A servomotor is a closed-loop servomechanism that uses position feedback to control its motion and final position. The input to its control is a signal (either analogue or digital) representing the position commanded for the output shaft.

Bluetooth module can easily achieve serial wireless data transmission. Its operating frequency is among the most popular 2.4GHz ISM frequency band (i.e. Industrial, scientific and medical).This module is set with serial interface, which is easy to use and simplifies the overall design/development cycle.

Components needed for this Arduino Project
- Arduino Uno/nano
- Jumper Wire
- SG90 Micro Servo Motor
- HC-06/HC-05 Bluetooth Module
Circuit Schematics

Building Connection
- Connect the positive pin of Servo Motor with 5v pin of Arduino board.
- Connect the negative pin of Servo Motor with GND (Ground) of Arduino board.
- Connect the Signal pin of Servo Motor with pin no. 3 in Arduino board.
Interpretation of Code
1 ) To actuate Servo Motor it takes only a few lines of code. The first thing we have to do is include the library file for servo motor in our Arduino IDE thereafter we call the library in our code and Define the Servo name as global variable as written below.
#include <Servo.h>
Servo myservo;
2) The second thing we need to do is configure as an output signal pin connected to Servo Motor. We do this with a call to the in servo.attach() function, inside of the sketch’s setup() function:
void setup() {
myservo.attach(3); // attaches the servo on pin 3 to the servo Signal
}
3) Finally, we have to actuate the Servo Motor at a particular angle in the sketch’s loop(). We can do this with single calls to the myservo.write(x) function, where x is a variable through which we control the servo motor shaft angle, the Servo Motor shaft would turn at some angle too quickly for us to see, so we call to delay() function to give time interval between two lines of code. The delay function works with MILLISECONDS, so we pass it 1000 to pause for a second.
void loop() {
// sets the servo position value Between 0 to 180 Degree
myservo.write(0);
delay(1000);
myservo.write(90);
delay(1000);
myservo.write(130);
delay(1000);
myservo.write(160);
delay(1000);
myservo.write(180);
delay(1000);
}
Source Code
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
myservo.attach(3); // attaches the servo on pin 3 to the servo signal
}
void loop() {
// set the servo position value Between 0 to 180 Degree
myservo.write(0);
delay(1000);
myservo.write(90);
delay(1000);
myservo.write(130);
delay(1000);
myservo.write(160);
delay(1000);
myservo.write(180);
delay(1000);
}