Created
June 24, 2014 04:38
-
-
Save hagope/979bb3b0848e0dd4431d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://makezine.com/projects/tutorial-raspberry-pi-gpio-pins-and-python/ | |
import RPi.GPIO as GPIO | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) | |
GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP) | |
def printFunction(channel): | |
print(“Button 1 pressed!”) | |
print(“Note how the bouncetime affects the button press”) | |
GPIO.add_event_detect(23, GPIO.RISING, callback=printFunction, bouncetime=300) | |
while True: | |
GPIO.wait_for_edge(24, GPIO.FALLING) | |
print(“Button 2 Pressed”) | |
GPIO.wait_for_edge(24, GPIO.RISING) | |
print(“Button 2 Released”) | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment