add keyboard interrupt stop function
This commit is contained in:
parent
45991bf050
commit
76b90481f6
42
nexus.py
42
nexus.py
|
|
@ -37,21 +37,27 @@ class NexusRobot:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__'':
|
||||||
robot = NexusRobot('/dev/cu.usbserial-AL00YYCA')
|
try:
|
||||||
robot.forward(200,10)
|
robot = NexusRobot('/dev/cu.usbserial-AL00YYCA')
|
||||||
robot.pause()
|
while 1:
|
||||||
robot.turnRight(200,90)
|
robot.forward(200,20)
|
||||||
robot.pause()
|
robot.pause()
|
||||||
robot.forward(200,10)
|
robot.reverse(200,20)
|
||||||
robot.pause()
|
robot.pause()
|
||||||
robot.turnRight(200,90)
|
# robot.forward(200,10)
|
||||||
robot.pause()
|
# robot.pause()
|
||||||
robot.forward(200,10)
|
# robot.turnRight(200,90)
|
||||||
robot.pause()
|
# robot.pause()
|
||||||
robot.turnRight(200,90)
|
# robot.forward(200,10)
|
||||||
robot.pause()
|
# robot.pause()
|
||||||
robot.forward(200,10)
|
# robot.turnRight(200,90)
|
||||||
robot.pause()
|
# robot.pause()
|
||||||
robot.turnRight(200,90)
|
# robot.forward(200,10)
|
||||||
robot.pause()
|
# robot.pause()
|
||||||
|
# robot.turnRight(200,90)
|
||||||
|
# robot.pause()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
robot.stop()
|
||||||
|
except BasicException:
|
||||||
|
raise
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue