If you are looking to make Android app to control a servo motor, this is a perfect blog post for you, here you can follow a step by step procedure video to know how to make an android app using MIT app inventor and to control a servo motor. This app sends the angle for the servo from your android phone to your bluetooth connected to the Arduino. where the Arduino receives the angle and executes the program and set the angle to the servo motor.
What components that you need to make this?
Arduino Uno or any other microcontroller.
servo Motor
Bluetooth Module (HC-05)
Android phone :)
After completing the Program in MIT app inventor, go to Build and select App( save .apk to my computer)
if your mobile not allowing to install the app from unknown sources.
go to setting in your android mobile select security and move to Device administration and give access to allow install app from unknown sources.
Arduino Program:
___________________________________________________________________________________
#include <SoftwareSerial.h>
#include <Servo.h>
Servo myservo;
int bluetoothTx = 10;
int bluetoothRx = 11;
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup()
{
myservo.attach(9);
//Setup usb serial connection to computer
Serial.begin(9600);
//Setup Bluetooth serial connection to android
bluetooth.begin(9600);
}
void loop()
{
//Read from bluetooth and write to usb serial
if(bluetooth.available()> 0 )
{
int servopos = bluetooth.read();
Serial.println(servopos);
myservo.write(servopos);
}
}
No comments:
Post a Comment