Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/todbot/pico8enc
Lotsa Rotary Encoders on a Raspberry Pi Pico
https://github.com/todbot/pico8enc
circuitpython raspberrypipico rotary-encoder rotary-encoders
Last synced: 4 months ago
JSON representation
Lotsa Rotary Encoders on a Raspberry Pi Pico
- Host: GitHub
- URL: https://github.com/todbot/pico8enc
- Owner: todbot
- Created: 2021-04-06T03:06:10.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-07T21:04:55.000Z (almost 4 years ago)
- Last Synced: 2024-09-27T09:23:33.894Z (4 months ago)
- Topics: circuitpython, raspberrypipico, rotary-encoder, rotary-encoders
- Language: Python
- Homepage:
- Size: 8.47 MB
- Stars: 35
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pico8enc -- 8 rotary encoders on a Raspberry Pi Pico
Turns out you can hook up 8 rotary encoders w/ switches to
Raspberry Pi Pico with no extra hardware. Pretty cool!With CircuitPython, it becomes pretty easy to actually read these encoders
since all hard, timing-critical work is done inside the C-based `rotaryio`
library that comes standard with CircuitPython.
![]()
One "twist" to look out for (haha): the two rotary encoder pins must be hooked up
to adjacent pins on the Pico, because of how `rotaryio` uses the Pico's
PIO module to handle reading the encoder pulses.The core of the code looks like this:
```py
encoder_pins = ( (board.GP12, board.GP13, board.GP16), # pin A, pin B, pin for switch
(board.GP10, board.GP11, board.GP17),
(board.GP8, board.GP9, board.GP18),
(board.GP6, board.GP7, board.GP19),
# ...
)
encoders = []
encoder_buttons = []
for pins in encoder_pins:
pin_A, pin_B, pin_switch = pins
encoder = rotaryio.IncrementalEncoder( pin_A, pin_B )
button = DigitalInOut(pin_switch)
button.pull = Pull.UP
encoders.append(encoder)
encoder_buttons.append(button)while True:
for i in range(len(encoders)):
position = encoders[i].position
button_press = encoder_buttons[i].value```
![]()