Servos are one of the best things I like in electronics, and in this instructable I'm going to show you how to control a servo motor with your Linkit one and control the angle of the servo on a android phone. The Linkit One will communicate to android phone via Bluetooth, if you want to control it via WiFi you can check out my previous instructables.

Step 1: Components

Here is a list of all the components required to get started, make sure you collect all the components first before proceeding to other steps-


HC05 Bluetooth Module




Step 2: Schematics

The schematics can be found in the picture above, I had to use an Arduino to represent the Linkit one as Fritzing doesn't have a library for the Linkit one yet.

Step 3: Program

To upload the program you need to install the Linkit one plugin along with the arduino IDE. You can find instructions on how to do that in the official website. You can also download the IDE with the Linkit One plugin pre-installed from GitHub.

#define bluetooth Serial

Servo myServo;

char cmd[100]; int cmdIndex;

void exeCmd() { // "servo" is the servo motor id if(cmd[0]=='s' && cmd[1]=='e' && cmd[2]=='r' && cmd[3]=='v' && cmd[4]=='o' && cmd[5]==' ') { int val = 0; for(int i=6; cmd[i]!=0; i++) { val = val*10 + (cmd[i]-'0'); } // if cmd is "servo 1234", val will be 1234 myServo.writeMicroseconds(val); } }

void setup() { delay(500); // wait for bluetooth module to start

bluetooth.begin(115200); // Bluetooth default baud is 115200 myServo.attach(4, 1000, 2000); cmdIndex = 0; }

void loop() { if(bluetooth.available()) { char c = (char)bluetooth.read(); if(c=='\n') { cmd[cmdIndex] = 0; exeCmd(); // execute the command cmdIndex = 0; // reset the cmdIndex } else { cmd[cmdIndex] = c; if(cmdIndex<99) cmdIndex++; } } }

Step 4: Android App

For the android phone you need the RoboRemo app from the android Playstore you need to pair the android phone with the bluetooth module and the default password for most of the modules is "1234". After pairing the board connect to the board using the app.

<p>Nice...What voltage is your servo my servo never run correctly in linkit one board</p>

About This Instructable




More by ImGokul:Serial Communication - Arduino and Linkit One Linkit One Temperature Sensor  Linkit One Motion Sensor  
Add instructable to: