Ramesh
Published © GPL3+

Bluetooth Controlled Servo

Learn how to control servo motors using an Android application in a mobile device, an Arduino UNO, and HC-05 Bluetooth module.

AdvancedFull instructions provided20,195
Bluetooth Controlled Servo

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1

Software apps and online services

MIT App Inventor 2
MIT App Inventor 2

Hand tools and fabrication machines

10 Pc. Jumper Wire Kit, 5 cm Long
10 Pc. Jumper Wire Kit, 5 cm Long
Breadboard, 170 Pin
Breadboard, 170 Pin

Story

Read more

Schematics

bt_servo_tut_bb_EdOYjrMa6l.png

Code

BT_servo.ino

Arduino
#include <Servo.h>

Servo myservo;


const int Pin = 9; // 
char Text;

String Spilt;

String angle;

int pos = 0;    // variable to store the servo position

int k1;


void setup() {

Serial.begin(9600);

pinMode (Pin, OUTPUT); 


myservo.attach(Pin);


}


void loop() {


  if(Serial.available())

  {

    Text = Serial.read();  

    Spilt = Spilt + Text; 


if (Text == '*') {

      Serial.println(Spilt);

      Spilt = Spilt.substring(0, Spilt.length() - 1); // Delete last char *

      k1 = Spilt.indexOf('*');

      angle = Spilt.substring(0, k1);

      myservo.write(angle.toInt());

      delay(15);  

  

      Spilt = "";   

  }

      }

 

} 

Credits

Ramesh
15 projects • 19 followers

Comments