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

rotary encoder

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

12 min read • Advanced
raspberry-pi-047.py
python
from gpiozero import RotaryEncoder
enc=RotaryEncoder(a=17,b=18,max_steps=0)
enc.when_rotated=lambda: print('steps:',enc.steps)
input('rotate; Enter to stop')
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content