Quote:
Originally Posted by Ianuser
Thanks, I see that now. But how do I stop the pwm03 motor? it wont just stop even though i set it to 127, because the next loop it is remapped to the joystick, so theres not enough time for me to let the joystick go back to 127 itself.
|
Define a static variable to be used as a "time to stop" flag. Whenever you detect the tape (or whatever you use to tell when you're at the right level), set the flag. Whenever the joystick reads 127 (or close enough), clear the flag. If the flag is set, stop the motor. If the flag is clear, copy the joystick value to the motor.