I am trying to make an automated door which opens/closes the door on receiving commands via Bluetooth.
All I want the servo to do is:
Remain steady on powering up the Arduino. (Currently it rotates to a certain angle and comes back on powering up Arduino).
Rotate from 0 degree to 90 degree and stops, on receiving another command it should rotate from 90 degree to 0 degree and stops.
This is my code :
else if (val=='i'){
myservo.write(0);
delay(4000);
for(pos = 0; pos <= 90; pos += 1){
myservo.write(pos);
delay(15);
}
}
else if (val=='j'){
myservo.write(0);
delay(4000);
for(pos = 90; pos >= 0; pos -= 1){
myservo.write(pos);
delay(15);
}
}