Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- button1_sensor_pin = 27
- button2_sensor_pin = 22
- def buttonCallback(gpioNum):
- if( gpioNum == button1_sensor_pin ):
- print('button 1 gedrückt')
- elif( gpioNum == button2_sensor_pin ):
- print("button 2 gedrückt")
- GPIO.setmode( GPIO.BCM )
- GPIO.setup( button1_sensor_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
- GPIO.setup( button2_sensor_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
- print ("linker buttons pin %d and %d"%(button1_sensor_pin,button2_sensor_pin))
- GPIO.add_event_detect(button1_sensor_pin, GPIO.RISING, callback=buttonCallback, bouncetime=500)
- GPIO.add_event_detect(button2_sensor_pin, GPIO.RISING, callback=buttonCallback, bouncetime=500)
- print "Taste zum beenden drücken"
- try:
- raw_input()
- except KeyboardInterrupt:
- print " bye bye "
- GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement