-
-
Save Phasip/3814635ba16c19c5f2af 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
#!/usr/bin/python | |
import time | |
import RPi.GPIO as GPIO | |
inpin = 11 #BCM17 | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(inpin,GPIO.IN, pull_up_down=GPIO.PUD_UP) | |
def simple(): | |
while True: | |
time.sleep(0.1) | |
curr = GPIO.input(inpin) | |
print(str(curr)) | |
def event(): | |
def myE(ch): | |
curr = GPIO.input(inpin) | |
print(str(curr)) | |
GPIO.add_event_detect(inpin, GPIO.BOTH, callback=myE, bouncetime=300) | |
while True: | |
time.sleep(1) | |
try: | |
event() | |
finally: | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment