Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- #from gopigo import * make sure to remove before sending
- import sys
- import time
- import random
- def print_menu():
- print ("w = Foward")
- print ("a = Turn left")
- print ("s = Backward")
- print ("d = Turn right")
- print ("x = Stop ")
- print ("t = Increase the speed by 10")
- print ("g = Decrease the speed by 10")
- print ("y = Turn the LEDs on and off")
- print ("? = Print the menu again")
- print ("z = Exit")
- valid_inputs = ['w','a','s','d','n','m','x','t','g','h','l','?','z']
- def main():
- while True:
- print_menu()
- choice = input()
- if choice == '1':
- drive()
- elif choice == '2':
- dance()
- elif choice == '3':
- led()
- elif choice == '4':
- servo()
- elif choice == '5':
- exit()
- elif choice == '?':
- print_menu()
- else:
- print ("Invalid input. Look at the menu and enter again.")
- def movement():
- while choice != "z": #continue looping
- if input =='w': fwd()
- elif input =='a': left()
- elif input =='d': right()
- elif input =='s': motor_bwd()
- elif input =='x': stop()
- elif input =='t': increase_speed (10)
- elif input =='g': decrease_speed (10)
- else:
- print("ERROR?")
- def led():
- ledOn = False
- while True:
- if ledOn == True:
- choice = input("Do you want to turn the lights off? z to quit.")
- if choice == "y":
- ledOn = False
- elif choice == "z":ledOn = False
- break
- elif ledOn == False:
- choice = input("Do you want to turn the lights on?")
- if choice == "y":
- ledOn = True
- elif choice == "z":
- ledOn = False
- break
- else:
- print("The lights are off!")
- def dance():
- ['w', 'a', 'd', 's', 'x', 't', 'g', 'z']
- random choice ['w', 'a', 'd', 's', 'x', 't', 'g', 'z']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement