Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. import RPi.GPIO as GPIO #GPIO Libraries
  2. from time import sleep #Sleep Functions
  3. import readchar
  4.  
  5. GPIO.setmode(GPIO.BCM) #Setting Up
  6.  
  7. GPIO.setup(23, GPIO.OUT)#Right Motor Forwards
  8. GPIO.setup(24, GPIO.OUT)# Backwards
  9. GPIO.setup(17, GPIO.OUT)#Left Motor Backwards
  10. GPIO.setup(27, GPIO.OUT)# Forwards
  11.  
  12.  
  13. print("Welcome to the Awesome Robot!!!")
  14. sleep(2)
  15.  
  16. while True:
  17.  
  18. key=readchar.readkey()
  19.  
  20. if key=="1":
  21. GPIO.output(17, GPIO.HIGH)
  22. GPIO.output(24, GPIO.HIGH)
  23. sleep(1)
  24. GPIO.output(17, GPIO.LOW)
  25. GPIO.output(24, GPIO.LOW)
  26.  
  27.  
  28. elif key=="2":
  29. GPIO.output(17, GPIO.HIGH)
  30. sleep(1)
  31. GPIO.output(17, GPIO.LOW)
  32.  
  33. elif key=="3":
  34. GPIO.output(24, GPIO.HIGH)
  35. sleep(1)
  36. GPIO.output(24, GPIO.LOW)
  37.  
  38. elif key=="4":
  39. GPIO.output(27, GPIO.HIGH)
  40. GPIO.output(23, GPIO.HIGH)
  41. sleep(1)
  42. GPIO.output(27, GPIO.LOW)
  43. GPIO.output(23, GPIO.LOW)
  44.  
  45. elif key=="z":
  46. GPIO.cleanup()
  47. sleep(1)
  48. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement