Control Servo angle with BT

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.

HC-05 FUNCTION

Components needed for this Arduino Project

  1. Arduino Uno/nano
  2. Jumper Wire
  3. SG90 Micro Servo Motor
  4. HC-06/HC-05 Bluetooth Module

Circuit Schematics

Control Servo angle with BT

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);      
}
 

LPG Gas Leakage Detection using Arduino

LPG Gas Leakage Detection using Arduino Nowadays, fire accidents and blasts due to LPG gas leakage is the major problem....
Read More
Alcohol Detection using Arduino

Alcohol Detection using Arduino

Alcohol Detection using Arduino The alcohol detector sensor is specially referred to as a MQ3 sensor which detects alcohol in...
Read More
Led brightness control

Led brightness control

Led brightness control/fade LED Led brightness control Overview : With the help of Arduino UNO/nano PWM pin controlling the glow...
Read More
Obstacle Detector Robot

Obstacle Detector Robot

Obstacle Detector Robot An Obstacle Avoidance Robot is an intelligent robot, that can automatically sense and overcome obstacles on its...
Read More

Control Servo angle with BT

Control Servo angle with BT                In this Arduino Tutorial we will show you...
Read More

LED ON and OFF

LED ON and OFF               In this Arduino Tutorial we will show you how...
Read More

Simple LDR circuit

Simple LDR circuit overview : To understand the circuit and working of LDR (Light Dependent Resistor) with the help of arduino. List...
Read More
Servo Motor Interfacing

Servo Motor Interfacing

Servo Motor Interfacing            A servo motor uses servo mechanism, which is a closed loop mechanism...
Read More

LED Light Blinking

LED Light Blinking                In this Arduino Tutorial we will show you how you...
Read More
Name (required)E-mail (required)Website

Leave a Reply