To follow along with this guide, you'll need the following parts:
- A rotary encoder. This guide uses a 24-pulse mechanical, incremental rotary encoder with a push button switch. It fits onto a breadboard to make it easy to connect to a microcontroller board.
-
An ItsyBitsy M0 Express or other CircuitPython capable board. You'll need a microcontroller board to run the code in this guide. This guide uses the ItsyBitsy M0 Express. You can use any CircuitPython Express board. Note that at this time, Gemma M0, Trinket M0, STM32, and other non-Express boards do not support
rotaryio
- A USB Micro/A data cable. You'll need a known-good USB data cable! If your board isn't working, try a different cable. There are many USB cables that are only used for charging, and those will not work for this project.
- A breadboard and jumper wires. You'll need these to connect up the rotary encoder and the ItsyBitsy M0 Express.
Wiring
The rotary encoder has 5 pins total. Three are for the rotary encoder and two are for the button switch. The rotary encoder pins are A, C (common ground), and B, in that order when the rotary encoder is upright, i.e. oriented so the three pins are facing you.
We're going to be using both the rotary encoder and the push button switch for this guide. The following wiring diagram shows wiring up the rotary encoder to the ItsyBitsy to match the code example.
You can wire it however you like to your CircuitPython Express board - just remember to also update the pin #'s in the code!
- Connect one button switch pin on the rotary encoder to ground on the ItsyBitsy (top black wire)
- Connect one button switch pin on the rotary encoder to the D12 pin on the ItsyBitsy (green wire)
- Connect the C (common ground) pin on the rotary encoder to the ground pin on the ItsyBitsy (middle black wire)
- Connect the A pin on the rotary encoder to the D10 pin on the ItsyBitsy (yellow wire)
- Connect the B pin on the rotary encoder to the D9 pin on the ItsyBitsy (blue wire)
Page last edited March 08, 2024
Text editor powered by tinymce.