As it turns out EC11 rotary encoders fit nicely over a Seeed XIAO form factor module. This could prove to be useful as an extremely minimal macropad.
Some tabs need to be clipped off from the stock encoder as shown in the image below. It is okay if the metal housing of the encoder makes contact the shield of the XIAO module as both metal components should be connected to common ground by default.
Take care to not use too much solder when connecting the encoder pins. Excess solder may interfer with the case.
The sample code provided moves the mouse around in varying sized steps. The step size is adjusted by turning the encoder, and the movement is toggled on and off with the encoder switch.
This example can easily be adapted for additional use cases such as scrolling, zooming, volume, etc.
The key is to configure the pins that connect to the encoder's common (GND) pins as digital output low so that switch and encoder work as usual.
#include <Encoder.h>
#define SW_GND 5
#define SW_PIN 3
#define ROT_B 10
#define ROT_GND 9
#define ROT_A 8
Encoder encoder(ROT_A, ROT_B);
void setup() {
pinMode(SW_GND, OUTPUT);
pinMode(ROT_GND, OUTPUT);
digitalWrite(ROT_GND, LOW);
digitalWrite(SW_GND, LOW);
pinMode(SW_PIN, INPUT_PULLUP);
}
A small 3D printable case is provided in the STLs folder. It is shown here below. The top section of the case might benifit from supports for the encoder nut cutout. The case is designed for use with self tapping M2.5 screws.
Part | Quantity |
---|---|
EC11 Rotary Encoder | 1 |
Seeed XIAO | 1 |
Encoder Knob | 1 |
Self Tapping M2.5 Screws | 4 |