Introduction: PC Volume and Media Controller
My PC setup includes a pair of active speakers that don't have a separate volume control. Having to navigate to the windows volume every time to set the volume setting was a bit frustrating so I wanted to come up with an easier solution.
The controller itself is just a rotary encoder that detects the direction of rotation and sends commands to PC accordingly. I also added a play/pause button. The circuit is very simple so if you wan't to add more buttons (e.g forward, backward, stop...) that can be done easily by replicating the circuit concerning the push button in the schematic.
The actual volume controlling is done by a small windows app written in C# that simulates keyboard media key presses.
Step 1: Hardware
The schematic is very simple. More buttons can be added just by replicating the circuit seen in the schematic. I assembled the circuit to a perfboard an installed it in to a small enclosure. I used a 9-core data cable to connect the Arduino and the enclosed encoder. Regarding the encoder the number of steps per revolution is not critical but anything above 10 will do fine.
Parts:
Rotary encoder (for example one or another )
220 ohm resistor
LED
3x 10k ohm resistors
Wire
Enclosure
Knob for the encoder
Perfboard
Arduino (I used a cheap copy of Arduino Nano)
Momentary push button
Step 2: Software and Arduino Code
It is also possible to program the Arduino to be a HID device so that no external app would be needed (more about the topic can be found here). But I chose to use a Windows app because I have intentions to modify the project in the near future.
The controller communicates with PC over the serial bus. I wrote a small C# program that runs in windows in the background and can be accessed from the windows notification area by double clicking. The program saves the previous settings so they don't need to be set every time. I've also set the program to run every time I boot up my operating system (instructions can be found here). I've included the C# files so that the app can be easily modified.
The Arduino code is pretty simple. The controller sends command bytes to the serial bus according to the operation (button push, encoder clockwise or encoder anticlockwise). The windows application receives the bytes and simulates key presses accordingly. I made the code as simple as possible so it'd be easy to modify.
19 Comments
3 years ago
Brother, i love you. You app saved my academic work. I was getting white hair trying to solve the atmega16u2 problem on uno because all tutorials said it can't work as a HID keyborad and your tutorial saved me. Thank you so much.
Question 4 years ago
Hello.
I am want to make such volume knob, but I would like it to be less, if possible.
Did somebody did manage to make it; or though about it.
I am looking for a bluetooth module that can handle HID, to transmit keyboard data, and a battery for it to be wireless.
Can somebody recommand some advices module please:
Thx
5 years ago
Could you please give the circuit diagram in case that i want to add 2 more buttons ex. Next/Previous? Thanks.
5 years ago
Great job my friend, what would be the difference in making a subwoofer volume controller for and underdash mount in my car? (Forgive my ignorance) ;)
6 years ago
Hello,
nice work :). I tried to do it but something went wrong. When I push the button it works, but only one time, If I'll push again it doesn't work. I tried to check and change some value on the arduino code, but without success.
Can you help me?have any suggestion? by the way I tried both apps whit mute and play /pause function, same result,
thank you
Reply 6 years ago
Hi,
You could try to monitor the serial port from the Arduino IDE to make sure that it sends out the right messages. This way you can pinpoint whether the problem is caused by the program or the Arduino.
Reply 6 years ago
Hi,
thanks for your answer.
So I have tried with serial monitor of Arduino (even without program), first time I push the button I can see on the serial monitor the number 3 (and this is what I expect), but after the first time, the number three don't come out again, only the function "volume UP" and "volume DOWN" still work.
I Hope it was clear, sorry for my bad english.
thanks
6 years ago
Very useful! There is no sound buttons on my keyboard, I'm very glad to have found this project! Thank you, pertti56!
6 years ago
can you post it?I don t have any "skills"in coding
6 years ago
nice project ,can you modify the project instead of play pause to be volume mute?
Reply 6 years ago
Sure, with the library used it's easy to use any windows media key function. The Functionality can be changed just by altering one word in the code.
7 years ago
Nice project
Is it possible to use this as a volume control on windows and control for example game volume, web browser volume and skype volume separately? Is it possible to change the rotary encoder to volume sliders and with the sliders you could control separately game volume, web browser volume and skype volume? How can I change the rotary encoder to sliders and where i have to connect the sliders. Is this even a possible to change rotary encoder to volume sliders?
Reply 7 years ago
Or is it possible to add more rotary encoders to control the volumes?
Reply 7 years ago
The things you've suggested are indeed possible but there is a major difference when using a potentiometer (a slider) to set the volume. When you use a potentiometer you must sense to position of the slider and map the position to range from 1 to 100. That is very easy. Then the value read from the potentiometer must be set as the value of the system or program volume and that is when it gets complicated. Accessing windows volume information and setting it numerically involves pretty advanced software coding (and at the moment I've still learning to do so...).
The way my project gets around the problem that it simulates keyboard button presses so I don't have to access the operating system itself. Although if you really wanted to use a slider instead of rotary encoder you could modify the program so that it set's the windows master volume to 0 at startup and then simulates the key presses the number of times that is set with the slider. Although the method described is pretty unorthodox when it comes to software developing...
Reply 7 years ago
Thanks for your answers. The product on the link is what I meant. I need to think what should I do because I want to make device which allows me to control windows volumes separately. But it's not necessary for me to have pontentiometers instead rotary encoders. So I could just add more rotary encoders. But the problem is the code because I don't have any idea how to make the code so it allows to change volumes separately. And devices on the shops are too expensive.
Reply 7 years ago
I guess this is what you are after: https://www.kickstarter.com/projects/94625964/mixo...
Accessing windows mixer and separate volumes includes some more advanced programming.
7 years ago
Very nice project. I would like to make it but I'm a little bit confused. How do I connect it to the PC. Can you explain that? Thanks!
Reply 7 years ago
The controller connects to the PC with USB port (and it's used to transfer the serial data) found in the Arduino board or via separate USB to serial converter if your board doesn't have a USB connector. The serial to USB converter that is built in to the most Arduino boards makes the Arduino look like a serial (COM) device to the PC.
7 years ago
Nice project! I did a similar USB volume controller using an Arduino Pro Micro as a HID device. Would love to see what you will do in the future!