Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- import time
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(17,GPIO.IN,pull_up_down=GPIO.PUD_UP)
- GPIO.setup(18,GPIO.IN,pull_up_down=GPIO.PUD_UP)
- GPIO.setup(6,GPIO.IN,pull_up_down=GPIO.PUD_UP)
- GPIO.setup(23,GPIO.IN,pull_up_down=GPIO.PUD_UP)
- GPIO.setup(5,GPIO.OUT)
- def prints(CH) :
- print ('Button', CH, 'Pressed')
- try :
- GPIO.add_event_detect(17,GPIO.RISING,callback=prints,bouncetime=300)
- GPIO.add_event_detect(18,GPIO.RISING,callback=prints,bouncetime=300)
- GPIO.add_event_detect(6,GPIO.RISING,callback=prints,bouncetime=300)
- GPIO.add_event_detect(23,GPIO.RISING,callback=prints,bouncetime=300)
- while True :
- GPIO.output(5,1)
- time.sleep(0.2)
- GPIO.output(5,0)
- time.sleep(0.2)
- finally :
- GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement