I’ve just updated the code to move servo 1 back and forth whenever it detects the switch is
true (in one of the two positions).
Could you tell me which pins you’re using (I’ll update the code to save you having to correct it every time).
Something worth mentioning here is that the code currently reads the position of the switch as often as it possibly can. I’m not sure if digital pins read at the same speed as
analogRead, but if anything it’ll be faster and
On ATmega based boards (UNO, Nano, Mini, Mega), it takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second.
You can imagine this is unnecessary use of battery power so it would be worthwhile adding a delay in the loop but we can get into refinements once it’s working something like you want.