I created a quick program that uses the GPIO library to create an interrupt with a callback that is initiated when a (pink) button is pressed. It works, but when the button is pressed and then released slightly late I get another callback. Why is this? The interrupt is configured to only occur on a rising edge so I thought it should only occur on the button press. Is this just button bounce that occurs when I release the button?
The circuit is simply a button placed between pin 16 and a ground pin.
The python I'm using is below:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
pinkPin = 16
#set the pin to be high to start, low when pressed
GPIO.setup(pinkPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def pinkCall(channel):
print "Pink Callback"
def main():
GPIO.add_event_detect(pinkPin, GPIO.RISING, callback=pinkCall, bouncetime=500)
try:
raw_input()
except KeyboardInterrupt:
GPIO.cleanup()
GPIO.cleanup()
if __name__ == "__main__":
main()