I am making a car that is to be controlled by Android app through bluetooth. The problem that I am facing with servo motors is that before bluetooth module hc-05 gets connected to any bluetooth device, the servo motors rotate irrespective of whether it is connected or not.
Here's my arduino code for servo motors:
#include<Servo.h>
Servo servo1;
Servo servo2;
char val;
void setup()
{
Serial.begin(9600);
servo1.attach(5);
servo2.attach(9);
}
void loop()
{
if(Serial.available())
{
switch(Serial.read())
{
case 'F':
servo1.write(180);
servo2.write(180);
break;
case 'B':
servo1.write(90);
servo2.write(90);
break;
}
}
}
I don't know why it' rotating. It's very frustating. Plz help. By the way the servo motors that I bought rotates only 180 degree.But I made it 360 degree by removing some part from inside. Plz help and correct me if my code is wrong.