def followLine(seconds): timeOut=time.time()+seconds while time.time()<timeOut: while fct.readNameColour() != 1: if fct.readColour()<70 and fct.readColour()>=35: fct.goForward() elif fct.readColour()>=70 and fct.readColour()<80: fct.stop(9) fct.goSlowSpeedLeft() time.sleep(0.02) fct.stop(9) elif fct.readColour()>=80: fct.stop(9) fct.goFullSpeedLeft() time.sleep(0.01) fct.stop(9) elif fct.readColour()<35 and fct.readColour()>27: fct.stop(9) fct.goSlowSpeedRight() time.sleep(0.02) fct.stop(9) else: fct.stop(9) fct.goFullSpeedRight() time.sleep(0.01) fct.stop(9) fct.stop(9) break
def react(c): if c in [ord('q'), 27, 32]: stop() return elif c == curses.KEY_LEFT: fct.goFullSpeedLeft() elif c == curses.KEY_RIGHT: fct.goFullSpeedRight() elif c == curses.KEY_UP: fct.goForward() elif c == curses.KEY_DOWN: fct.goBackward()