I have a 4.8 volt servo motor connected to a power supply module. I am powering the module with a 9 volt battery. When I use code to have the motor sweep the servo will usually move but will sometimes not move. When I set code to move the servo to a particular angle it does not move at all.
Sweep Code:
'''
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
servo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
servo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
'''
move code:
'''
angle = 90;
servo.write(angle);
delay(2000);
angle = 0;
servo.write(angle);
delay(2000);
'''