I found very few solutions that would allow me to execute repetitive keyboard actions. It is something that could be useful when working with Lightroom or Photoshop in order to quickly reverse a few actions back and forth to visualise the result.
All commercial items I found are task specific and not very customisable so I decided to build my own.
By using the push button on the rotary encoder I should be able to switch between pre-defined shortcut and get a visual feedback using the NeoPixel ring.
I also want to make something accessible to anyone and easy to reproduce.
DetailsCurrent Status
The knob in action:
The code is here: https://github.com/vincentmakes/InfinityUSBKnob
Hardware
This is the hardware we will use for this project:
A Trinket M0, EC11 rotary knob, a NeoPixel ring, a nicer knob and an aluminium case from audiophonics.
What I Want to Achieve
Several mode will be available at each push of the rotary knob, allowing to switch between shortcut possibilities such as volume up/down and undo/redo.
Connections
The connections are quite straightforward. The A, B, C pin of the encoder are going to the pin 1, 2 and 3 of the Trinket.
Pin 4 is connected to the DI of the ring.
The power consumption is not very high when the brightness is set to 24
The CodeHere's what I'm using and the challenges I faced:
Controlling the LED: Just using the NeoPixel Library for Arduino. There are two types of animations I want to cover:
1. Turning on LEDs clockwise, turning off LEDs counterclockwise until one LED only is on. Stopping at LED of origin. This is for Undo/Redo actions with finite history.
2. Turning on LEDs clockwise, turning off LEDs countreclockwise but also turning on LEDs further counterclockwise if it passes the LED of origin. This is for volume up/down or any "unlimited" action.
Reading the encoder: the trick is to trigger an action on interrupt to detect when the knob is turned. Therefore the main code will not be in the loop() function but rather in the function called on interrupt.
Sending keyboard commands: I will be using the HID-Project Library. This is important to not use the default Keyboard.h library provided by Arduino because the HID library already includes it. The difference is that some actions are not just keyboard shortcut but requires to interact with the HID. The volume up/down is one of them for example and triggering F11/F12 will not work.
CasingAnything will work here but I stumble upon this aluminium case that I will re-purpose for the project. I will simply drill holes to mount the knob and be able to see the LEDs. I have attached a template to mark the holes.
Here's some measurement for the drilling/tapping:
After drilling and tapping
Filling the holes with epoxy
The NeoPixel ring fits into the casing after machining the inside. Although I had to make a poor's man lathe using a drill and a file to remove 1mm of the wall.
and here it is after jamming everything in there and closing it
neopixel_scale.pdf: template for marking holes
Comments