Advertisement
cymplecy

pibrellatest

Jan 15th, 2017
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. import time
  2.  
  3. TIME = 0.1
  4. import anyio.GPIO as GPIO
  5. from threading import Thread
  6. BUTTON = 23
  7. INPUTA = 21
  8.  
  9. RED =13
  10. YEL =11
  11. GRN=7
  12. GPIO.setmode(GPIO.BOARD)
  13.  
  14. GPIO.setup(RED, GPIO.OUT)
  15. GPIO.setup(YEL, GPIO.OUT)
  16. GPIO.setup(GRN, GPIO.OUT)
  17.  
  18. GPIO.setup(BUTTON, GPIO.IN)
  19. GPIO.output(GRN, True)
  20.  
  21. def pinread():
  22.     while True:
  23.         time.sleep(TIME)
  24.         print "input A" , GPIO.input(INPUTA)
  25.  
  26. def pinwrite():
  27.     while True:
  28.         GPIO.output(GRN, False)
  29.         GPIO.output(YEL, True)
  30.         time.sleep(TIME * 10)
  31.         GPIO.output(YEL, False)
  32.         GPIO.output(RED, True)
  33.         time.sleep(TIME * 30)
  34.         GPIO.output(YEL, True)
  35.         time.sleep(TIME * 10)
  36.         GPIO.output(RED, False)
  37.         GPIO.output(YEL, False)
  38.         GPIO.output(GRN, True)
  39.         time.sleep(TIME * 30)
  40.  
  41. try:
  42.     i = Thread(target=pinread)
  43.     i.start()
  44.     o = Thread(target=pinwrite)
  45.     o.start()
  46. finally:
  47.     GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement