Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
menu_book Course Curriculum (Raspberry Pi) expand_more
Raspberry Pi / GPIO Digital I/O

edge detection

Learn edge detection in Raspberry Pi with a dedicated explanation, a concept-specific example, practical cautions, and a mastery check.

12 min read • Beginner
raspberry-pi-016.py
python
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM); GPIO.setup(2,GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.add_event_detect(2,GPIO.FALLING,callback=lambda ch: print('pressed'),bouncetime=100)
input('Enter to stop'); GPIO.cleanup()
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content