Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- TIME = 0.1
- import RTk.GPIO as GPIO
- from threading import Thread
- BUTTON = 23
- INPUTA = 21
- RED =13
- YEL =11
- GRN=7
- GPIO.setmode(GPIO.BOARD)
- GPIO.setup(RED, GPIO.OUT)
- GPIO.setup(YEL, GPIO.OUT)
- GPIO.setup(GRN, GPIO.OUT)
- GPIO.setup(BUTTON, GPIO.IN)
- GPIO.setup(INPUTA, GPIO.IN)
- GPIO.output(GRN, True)
- def pinread():
- while True:
- time.sleep(TIME *2)
- print (time.strftime("%b %d %Y %H:%M:%S", time.gmtime()))
- print ("input A" , GPIO.input(INPUTA))
- def pinwrite():
- print ("green")
- while True:
- GPIO.output(GRN, False)
- print ("amber")
- GPIO.output(YEL, True)
- time.sleep(TIME * 10)
- print ("red")
- GPIO.output(YEL, False)
- GPIO.output(RED, True)
- time.sleep(TIME * 30)
- print ("red and amber")
- GPIO.output(YEL, True)
- time.sleep(TIME * 10)
- print ("green")
- GPIO.output(RED, False)
- GPIO.output(YEL, False)
- GPIO.output(GRN, True)
- time.sleep(TIME * 30)
- i = Thread(target=pinread)
- i.start()
- o = Thread(target=pinwrite)
- o.start()
- while True:
- time.sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement