#! /usr/bin/python
import
RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
btn = 19
count = 0
# Set up
Switch as input with pull up resistor.
# If you
wired a pull up resistor as well that is OK
GPIO.setup(btn, GPIO.IN, GPIO.PUD_UP)
# Set up
event detect
GPIO.add_event_detect(btn, GPIO.FALLING,
callback=buttonDown, bouncetime=delay)
#
Callback function
def
buttonDown(channel):
global count
count = count + 1
print
(count)
# Loop
forever - the time sleep is so that this is not
a
# CPU
hog. This is probably
not required as
# Linux
will lower the process priority.
while True:
time.sleep(.1)