Hi all!
I've got this program (code below) that isn't working as expected. There must me something wrong with the timer. Could you help me find out what?
Scenario:
The forward button is pressed, then the right button is pressed.
Actual result:
The right wheel start turning and keep turning indefinitely.
Expected result:
The right wheel starts turning and then stops after one second.
Program:
onevent button.center
when button.center == 1 do
motor.left.target = 0
motor.right.target = 0
call leds.top(32,0,0)
end
onevent button.forward
when button.forward == 1 do
call leds.top(6,26,0)
while not (button.center == 1) do
if button.right == 1 then
motor.right.target = -100
timer.period[0] = 1000
call leds.top(32,13,0)
end
if button.left == 1 then
motor.right.target = 100
timer.period[0] = 1000
call leds.top(32,26,0)
end
end
end
onevent timer0
motor.left.target = 0
motor.right.target = 0
call leds.top(6,6,32)
Best regards,
Emmanuel