Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from gopigo import * #Has the basic functions for controlling the GoPiGo Robot
- import sys
- print("Press:\n\tw: Move GoPiGo Robot forward\n\ta: Turn GoPiGo Robot left\n\td: Turn GoPiGo Robot right\n\ts: Move GoPiGo Robot backward\n\tt: Increase speed\n\tg: Decrease speed\n\tx: Stop GoPiGo Robot\n\tz: Exit\n")
- # A loop for taking user commands and peform the action. Continue the same until user press z letter
- while True:
- print ("Enter the Command to perform the Action")
- a=raw_input() # Fetch the input from the terminal
- if a=='w':
- print("Moving forward")
- fwd() # Move forward
- elif a=='a':
- print("Turing Left")
- left() # Turn left
- elif a=='d':
- print("Turning Right")
- right() # Turn Right
- elif a=='s':
- print("Moving Back")
- bwd() # Move back
- elif a=='x':
- print("Stopping")
- stop() # Stop
- elif a=='t':
- increase_speed() # Increase speed
- elif a=='g':
- decrease_speed() # Decrease speed
- elif a=='z':
- sys.exit()
- else:
- print("Soory. Wrong Command, Please Enter Again")
- time.sleep(.1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement