
Smooth dynammic servo motion
Our robot requires servos to move smoothly based on user input whithout interrupting any other functions. I wrote this code, and felt that maybe beginner programmers would benifit from it. Also, if anybody has a way to make this more efficient (without using multitasking, because this is for beginner programmers) please let me know.
We wanted to move the servo up if button 6U is pressed, and down if button 6D is pressed. This is more complicated than it sounds, because if you do this:
then the servo will go fully up as soon as you press the button, because the microprocessor cycles through the loop hundreds of times while you are holding the button.
now if we do this:
then the other controls get interrupted while the program is waiting, and time sensetive functions get messed up.
My solution was to use timers like this:
That's it. Comment if you have questions or see a problem. Thanks.