Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.98 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. #from gopigo import * make sure to remove before sending
  3. import sys
  4. import time
  5. import random
  6.  
  7. def print_menu():
  8.     print ("w = Foward")
  9.     print ("a = Turn left")
  10.     print ("s = Backward")
  11.     print ("d = Turn right")
  12.     print ("x = Stop ")
  13.     print ("t = Increase the speed by 10")
  14.     print ("g = Decrease the speed by 10")
  15.     print ("y = Turn the LEDs on and off")
  16.     print ("? = Print the menu again")
  17.     print ("z = Exit")
  18. valid_inputs = ['w','a','s','d','n','m','x','t','g','h','l','?','z']
  19. def main():
  20.     while True:
  21.         print_menu()
  22.         choice = input()
  23.     if choice == '1':
  24.         drive()
  25.     elif choice == '2':
  26.         dance()
  27.     elif choice == '3':
  28.         led()
  29.     elif choice == '4':
  30.         servo()
  31.     elif choice == '5':
  32.         exit()
  33.     elif choice == '?':
  34.         print_menu()    
  35.     else:
  36.         print ("Invalid input. Look at the menu and enter again.")
  37.  
  38. def movement():
  39.     while choice != "z": #continue looping
  40.         if input =='w': fwd()
  41.         elif input =='a': left()
  42.         elif input =='d': right()
  43.         elif input =='s': motor_bwd()
  44.         elif input =='x': stop()
  45.         elif input =='t': increase_speed (10)
  46.         elif input =='g': decrease_speed (10)
  47.         else:
  48.             print("ERROR?")
  49.  
  50. def led():
  51.     ledOn = False
  52.     while True:
  53.         if ledOn == True:
  54.             choice = input("Do you want to turn the lights off? z to quit.")
  55.             if choice == "y":
  56.                 ledOn = False
  57.     elif choice == "z":ledOn = False
  58.         break
  59.         elif ledOn == False:
  60.             choice = input("Do you want to turn the lights on?")
  61.         if choice == "y":
  62.             ledOn = True
  63.         elif choice == "z":
  64.             ledOn = False
  65.         break
  66.    
  67.         else:
  68.             print("The lights are off!")            
  69.  
  70. def dance():
  71.     ['w', 'a', 'd', 's', 'x', 't', 'g', 'z']
  72.     random choice ['w', 'a', 'd', 's', 'x', 't', 'g', 'z']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement