Advertisement
cymplecy

pibrellatest

Jan 16th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. import time
  2.  
  3. TIME = 0.1
  4. import RTk.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.setup(INPUTA, GPIO.IN)
  20. GPIO.output(GRN, True)
  21.  
  22. def pinread():
  23.     while True:
  24.         time.sleep(TIME *2)
  25.         print (time.strftime("%b %d %Y %H:%M:%S", time.gmtime()))
  26.         print ("input A" , GPIO.input(INPUTA))
  27.  
  28. def pinwrite():
  29.     print ("green")
  30.     while True:
  31.         GPIO.output(GRN, False)
  32.         print ("amber")
  33.         GPIO.output(YEL, True)
  34.         time.sleep(TIME * 10)
  35.         print ("red")
  36.         GPIO.output(YEL, False)
  37.         GPIO.output(RED, True)
  38.         time.sleep(TIME * 30)
  39.         print ("red and amber")
  40.         GPIO.output(YEL, True)
  41.         time.sleep(TIME * 10)
  42.         print ("green")
  43.         GPIO.output(RED, False)
  44.         GPIO.output(YEL, False)
  45.         GPIO.output(GRN, True)
  46.         time.sleep(TIME * 30)
  47.  
  48.  
  49. i = Thread(target=pinread)
  50. i.start()
  51. o = Thread(target=pinwrite)
  52. o.start()
  53.  
  54.  
  55. while True:
  56.     time.sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement