I'm trying to use a servo to jingle a bell directly attached to the servo.
In my code I do a variation on this:-
void loop()
{
press1 = digitalRead(button1);
if (press1 == LOW)
{
servo1.write(160);
}
else {
servo1.write(20);
}
}
Q1. How do I know the extremities of my servo? I've looked at
the datasheet but I couldn't see any information there. I had to modify the above writes of 160 and 20 to other values before the servo was happy and didn't sort of hum or get stuck. I've also found I could make a bigger movement by increasing the 160 value - but how do I know where to stop?
Q2. If I use the code without a delay (which I cannot have in my project) then the servo darts only half way across the distance it would if there was a delay. Is there a way to get it to only begin moving back when it's reached the destination? Or do I have to use a millis style delay? Ideally, is there a library or function that would help with this?
Q3. Sometimes the servo chatters or moves a tiny bit independently of anything it's told to in the code. Is this normal for a cheap servo? Also, when powered from a battery it doesn't work as well as when powered from USB. This is with a brand new 9v battery. Confusing.
THANKS