Input example:
<
^
v
^
o
But the Thymio is just executing the last input, no matter hier I make use of the timer…
But my array doesn't work as expected. The robot should drive one command after the other, instead of just executing the last command in the array.
How do I have to fix it? http://www.ramsa.ma/UserProfile/tabid/42/userId/322104/Default.aspx
var go[5] = [0,0,0,0,0]
var j = 0
var i
var i2 = 0
var richtung
- stop timer 0
- timer.period[0] = 0
- reset outputs
call sound.system(-1)
call leds.top(0,0,0)
call leds.bottom.left(0,0,0)
call leds.bottom.right(0,0,0)
call leds.circle(0,0,0,0,0,0,0,0)
onevent button.center
when button.center == 1 do
while i < 5 do
if go[i] == 0 then
call leds.circle(32,0,0,0,0,0,0,0)
motor.left.target = 300
motor.right.target = 300
elseif go[i] == 1 then
call leds.circle(0,0,32,0,0,0,0,0)
motor.left.target = 300
motor.right.target = 0
elseif go[i] == 2 then
call leds.circle(0,0,0,0,32,0,0,0)
motor.left.target = -300
motor.right.target = -300
#timer.period[0] = 1000
elseif go[i] == 3 then
call leds.circle(0,0,0,0,0,0,32,0)
motor.left.target = 0
motor.right.target = 300
end
i = i + 1
end
#emit pair_run 5
end
onevent button.forward
when button.forward == 1 do
richtung = 0
go[i2] = 0
i2 = i2 + 1
#emit pair_run 0
end
onevent button.right
when button.right == 1 do
richtung = 1
go[i2] = richtung
i2 = i2 + 1
end
onevent button.left
when button.left == 1 do
richtung = 3
go[i2] = richtung
i2 = i2 + 1
#emit pair_run 2
end
onevent button.backward
when button.backward == 1 do
richtung = 2
go[i2] = richtung
i2 = i2 + 1
#emit pair_run 3
end
onevent timer0
timer.period[0] = 0
motor.left.target = 0
motor.right.target = 0
call leds.bottom.left(32,0,0)
call leds.bottom.right(32,0,0)