add keyboard interrupt stop function

This commit is contained in:
HappyZ 2017-12-20 15:36:43 -06:00 committed by GitHub
parent 45991bf050
commit 76b90481f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 18 deletions

View File

@ -37,21 +37,27 @@ class NexusRobot:
robot = NexusRobot('/dev/cu.usbserial-AL00YYCA')
robot.forward(200,10)
robot.pause()
robot.turnRight(200,90)
robot.pause()
robot.forward(200,10)
robot.pause()
robot.turnRight(200,90)
robot.pause()
robot.forward(200,10)
robot.pause()
robot.turnRight(200,90)
robot.pause()
robot.forward(200,10)
robot.pause()
robot.turnRight(200,90)
robot.pause()
if __name__ == '__main__'':
try:
robot = NexusRobot('/dev/cu.usbserial-AL00YYCA')
while 1:
robot.forward(200,20)
robot.pause()
robot.reverse(200,20)
robot.pause()
# robot.forward(200,10)
# robot.pause()
# robot.turnRight(200,90)
# robot.pause()
# robot.forward(200,10)
# robot.pause()
# robot.turnRight(200,90)
# robot.pause()
# robot.forward(200,10)
# robot.pause()
# robot.turnRight(200,90)
# robot.pause()
except KeyboardInterrupt:
robot.stop()
except BasicException:
raise