What your undelined code is doing is going from 0 to 180 in steps of 2 degrees... Each servo1.write(position)
is 2 degrees further than the last write, since the for's position += 2
is incrementing in 2's. (Zoomcat's is similar, but in 1's). BUT, each pass through the for also includes a delay(20)
(or 15 in zoomcat's example) which causes a pause of 20ms between each 2 degree movement step.
to read up on how "for" works.
Without that loop and delay, if the servo was at say 0 degrees and you sent it a servo1.write(180)
it would have gone from 0 to 180 as fast as it was able. Servo speed is quoted by the makers as the time to move through 60 degrees, such as 0.16 seconds for this one
. (That's the speed with no load, obviously slower when it's trying to move something.)