from movement import *
from sensor import *
from utime import sleep
junction_count = 0
def move_junction():
global junction_count
while get_juntion() == 0:
line_follow()
junction_count += 1
stop()
def line_follow():
line = getline()
if line == 1:
left()
elif line == 2:
left()
elif line == 3:
forward()
elif line == 4:
right()
elif line == 5:
right()
sleep(0.1)
stop() # stop motor
while getbutton() == 1: # wait button press
pass
while junction_count < 13:
print("junction_count", junction_count)
if junction_count == 0:
move_junction()
elif junction_count == 1:
left()
sleep(0.5)
move_junction()
elif junction_count == 2:
right()
sleep(0.5)
move_junction()
elif junction_count == 3:
right()
sleep(0.5)
move_junction()
elif junction_count == 4:
forward()
sleep(0.5)
move_junction()
elif junction_count == 5:
left()
sleep(0.5)
move_junction()
elif junction_count == 6:
left()
sleep(0.5)
move_junction()
elif junction_count == 7:
forward()
sleep(0.5)
move_junction()
elif junction_count == 8:
right()
sleep(0.5)
move_junction()
elif junction_count == 9:
right()
sleep(0.5)
move_junction()
elif junction_count == 10:
forward()
sleep(0.5)
move_junction()
elif junction_count == 11:
left()
sleep(0.5)
move_junction()
elif junction_count == 12:
left()
sleep(0.5)
move_junction()
elif junction_count == 13:
right()
sleep(0.5)
move_junction()