Intro
This is the opening salvo in my 4 project push. Rather than simply presenting a chronological documentary or a report format with objectives and dry design documents, I wanted to make it a bit more interactive, so I presented pictures of the system for viewers to creatively deduce what they were looking at. This added a lot of interesting ideas to the blog comments. This blog is now updated, including a new title (to make the blog more searchable) and information identifying what the project does. I would like to thank the commenters for making this simple project into a more interesting and entertaining blog.
This project was a result of my need for volume control of the speakers on my PC. The speakers have a volume control, but it is in an awkward location. I wanted something more convenient. My keyboard actually has function keys that can control volume, but I also find that an awkward method of volume control. It requires 2 keys to be pressed multiple times to reach a desired volume. The device shown here is an intuitive volume knob that can be positioned very conveniently. And I use it every day.
These are the clue images
- this view does not show any cables....
Here is the second image - showing an additional surface with the usual feline photobomber...
The next image will show the PCBs inside...
Okay - here is the exploded view....some of it should be quite recognizable...
Note how the main PCB slides into a slot making the set screw in the knob the only fastener in the system.
I had to play hockey this evening, so I didn't get around to a more complete description of the system, but I will try again tomorrow.
In the mean time - here is another picture of the assembled system....
Project Description
This device is a simple volume control for PC speakers.
It uses a Raspberry Pi Pico to read a mechanical rotary encoder and convert the rotation into HID keyboard volume control commands sent to a host PC via USB.
The Pi Pico is mounted on a custom PCB which simply provides connections between the Pico and the encoder.
Here is a schematic of the relevant connections:
Schematic
Firmware
# Pi Pico Volume Contrroller by Doug Wong 2025 # Pi Pico HID volume firmware # This program reads a mechanica rotary encoder that generates a quadrature signal on 2 pins # the up or down pulses are sent to the host computer via a HID USB driver that emulates a keyboard # the HID commands are volume controol instructions # import libraries import usb_hid import board import digitalio from adafruit_hid.keyboard import Keyboard from adafruit_hid.keycode import Keycode from adafruit_hid.consumer_control import ConsumerControl from adafruit_hid.consumer_control_code import ConsumerControlCode # Define pin numbers for the rotary encoder CLK_PIN = board.GP16 DT_PIN = board.GP17 SW_PIN = board.GP18 # debouncing variables clk_last = None count = 0 keyboard = ConsumerControl(usb_hid.devices) # Define Encoder pins clk = digitalio.DigitalInOut(CLK_PIN) clk.direction = digitalio.Direction.INPUT dt = digitalio.DigitalInOut(DT_PIN) dt.direction = digitalio.Direction.INPUT sw = digitalio.DigitalInOut(SW_PIN) sw.direction = digitalio.Direction.INPUT # Define USB HID volume control commands def ccw(): print("CCW") keyboard.send(ConsumerControlCode.VOLUME_DECREMENT) def cw(): print("CW") keyboard.send(ConsumerControlCode.VOLUME_INCREMENT) # Endless loop to read encoder and send volume commands while(1): clkState = clk.value if(clk_last != clkState): if(dt.value != clkState): cw() else: ccw() clk_last = clkState;
Discussion
This volume control device is a very simple build that uses parts I already had lying around. Normally I probably wouldn't design a PCB board just to connect an encoder, but I had a PCB that already included the right connections. I enjoyed the simplicity of the build and I really enjoy the convenience it provides for a function I use every day. One thing I may do to improve this device is to replace the knob with a more massive knob that would allow it to be spun and have its momentum continue spinning until it is stopped.
Again, I would like to say I enjoyed the interesting comments in response to the mystery images.