There are two problems to control digital servo(HD-1810MG) and HC-06 bluetooth module connection.
- When I put a specific number to servo(in the video, I put 45), it shakes too much and shows useless movements before get to the right angle. I have no clue why this happens. Should I add more code to control it correctly?
This is my code.
#include SoftwareSerial.h
#include Servo.h
Servo myServo;
int TxD = 10;
int RxD = 11;
SoftwareSerial bluetooth(TxD, RxD);
void setup() {
myServo.attach(9);
Serial.begin(9600); // start serial communication at 9600bps
bluetooth.begin(9600);
}
void loop() {
if (bluetooth.available()>0)
{
int servopos = bluetooth.read();
Serial.println(servopos);
myServo.write(servopos);
delay(100);
}
}
- I used Nexus 5X and apk app to pair with HC-06. It pairs well at the first time of connection, but it loose connection after servo moved once. Application said it is connected with bluetooth, but HC-06's LED is blinking(which means disconnected). How can I maintain connection with HC-06?
And I made apk app using MIT App Inventor 2.
I'm so new to arduino and I'm not in major of engineering. Please give me an advice!