#Escape the maze! from myro import * init("/dev/rfcomm1") def evade(): """ Express our displeasure at being blocked, and avoid the obstacle""" #Displeasure setLEDBack(1.0) beep(0.15,880,881) beep(0.20,564,564) setLEDBack(0.0) #Avoidance forward(1,0.5) turnLeft(1,0.3) def mainLoop(): free = False while( not free): # Head "backwards" unless something appears # in front of us or 3 seconds are up. while( timeRemaining(3)): l,r = getIR() backward(0.65) if( l == 0 or r == 0): stop() print "IR sensor hit!" evade() turnLeft(1) #Stutter step to avoid beep(0.1,1200,1201) #unsensed things every 3 seconds mainLoop()