View difference between Paste ID: 3N3V4H6f and sS0Hw39A
SHOW: | | - or go back to the newest paste.
1
import RPi.GPIO as GPIO
2
import time
3
4
GPIO.setmode(GPIO.BCM)  
5
6
GPIO.setup(4, GPIO.IN, pull_up_down = GPIO.PUD_UP)
7
8
def interrupt(channel):
9
    print(GPIO.input(4))
10
    
11
GPIO.add_event_detect(4, GPIO.BOTH, callback = interrupt, bouncetime = 50)
12
13
while True:
14
    time.sleep(1)
15
    # print(GPIO.input(4))
16
17
GPIO.cleanup()