The code looks a bit complicated, but since the servos move independently, you can keep separate direction flags, and toggle them when each servo reaches a limit...
Then use that flag to increment or decrement as appropriate during the run phase.
The code looks a bit complicated, but since the servos move independently, you can keep separate direction flags, and toggle them when each servo reaches a limit...
Then use that flag to increment or decrement as appropriate during the run phase.