I want to programm the Thymio, so he can find his way thru a Labyrinth (there are no dead ends in the labyrinth). But i'm trying to increase the Programm by kind of telling Thymio, from which way he came from.
So if there is a wall in front of him, he turns 90-degree to the right. If there is still a wall in front of him, he's turning 180-degree to left (or right) and move forward. If there is no wall after a his first 90-degree turn, then he moves forwards.
So there is no chance of going in the direction he came from.
My code from the Blockly looks like this:
onevent button.forward
when button.forward == 1 do
call leds.top(6,32,6)
motor.left.target = 100
motor.right.target = 100
end
onevent prox
when prox.horizontal[2] > 2000 do
call leds.top(32,0,0)
timer.period[0] = 800
motor.left.target = 300
motor.right.target = -300
end
onevent timer0
call leds.top(26,6,26)
if (prox.horizontal[2] > 2000 or prox.horizontal[3] > 2000) or prox.horizontal[1] > 2000 then
timer.period[1] = 1300
motor.left.target = -300
motor.right.target = 300
else
motor.left.target = 100
motor.right.target = 100
end
onevent timer1
call leds.top(32,19,0)
motor.left.target = 100
motor.right.target = 100
Can anyone help me please?