Introduction: Simple DIY Volume Control Knob!

Picture of Simple DIY Volume Control Knob!

Got a desktop with a sound system far from where you sit?--I do. After a bit of digging, I found that it was pretty easy to make my own soft volume control knob on the cheap.

In this tutorial I will show you how to create a USB volume control knob for your PC!

To keep things simple, Instead of Arduino, I will use an arduino compatible board called the Digispark. Not only is the Digispark small, but it is cheap! Normally I pick mine up from for less than $2 USD

Lets get started!

Step 1: What You Will Need...

Picture of What You Will Need...

What you will be needing:

Micro USB cable

Micro USB DIgispark (can't be full sized version)

Rotary encoder (also cheap on aliexpress)

Not needed (but nice to have): Some sort of enclosure and knob

Arduino IDE and digispark environment.

Step 2: Time to Get Everything Set Up.

Picture of Time to Get Everything Set Up.

I won't teach you how to use the Arduino Development Environment, there are plenty of tutorials for that on the web already. If you are not familiar with the Digispark, setup information can be found here:

Once set up, go to: and download the Library that we will be needing for this project. Extract the .zip file and place the "Adafruit-Trinket-USB-master" folder into C:\Users\ \Documents\Arduino\libraries

Then copy and paste the sketch found on the same webpage into the Arduino IDE and upload it to your digispark.


The reason that we can do this so easily is because Adafruit has a product called the Trinket that uses the ATtiny85 chip (they have developed this simple-to-use library to work with their trinket) but the DigiSpark also uses the ATtiny85 chip!--So we can very easily use the cheap digispark to run the code and save some money!

Anyway, download the library and go to step 3!

Step 3: The Wiring

Picture of The Wiring

Next we can start on the hardware. I shall now demonstrate my artistic skill by drawing a simple schematic for you...

Anyway, as you can see it is very simple and that is all there is to it!

Step 4: The Build!

Picture of The Build!

This is optional and depends on how you want the finished product to look (unless, of course, you just want it to sit on protoboard when you're done)

What I did was cut a small hole into a pill bottle and stick the rotary encoder though it, then I hot-glued the digispark inside the lid (remember to cut a small hole in the side of the lid for the micro USB port to connect to your computer)

Lastly I glued a piece of rubber mat to the bottom--that completes the base!

For the lid, I took the knob from an old broken stereo receiver and plopped that on top!


I also filled it with wax and iron pellets to give it a heavy quality feel, but you can watch the video to learn more about that in step 5.

Step 5: Finished!

That is it!

This video may or may not be useful to you, but check it out!

If you have any problems getting it to work, contact me here on Instructables or leave a comment on the youtube video!

Also, if you find that the rotation is reversed, try changing the following lines at the top of the sketch from:

#define PIN_ENCODER_A 0

#define PIN_ENCODER_B 2


#define PIN_ENCODER_A 2

#define PIN_ENCODER_B 0

Remember to check out some of my other instructables!


ForrestA3 (author)2017-09-01

Hey guys, I added mute to the code! Here is the source. OP i strongly think you should add this.

Connect one side of the button (presumably the built in one on your encoder) to VIN, then connect the other side to p1. You can even change it from mute to whatever you like. Towards the bottom of my file you will see the MUTE command. You can change it to any of the ones given here

But they dont all seem to work

You can even change it to whatever key you want

Kenokke (author)ForrestA32017-12-04

Im wondering if there is any way to make it work as scroll whell?

Kris S (author)ForrestA32017-09-01

Thank you!

Kris S (author)ForrestA32017-09-01

I've featured your comment!

gewkwn made it! (author)2017-11-17

i need ideas for knob...

revertex (author)gewkwn2017-12-31

Concrete knob!

Search youtube "How To Make a Concrete Volume Knob".

Kris S (author)gewkwn2017-11-19

Hmm you might walk down the hardware isle at your local home Depot and see what you find.

gewkwn (author)Kris S2017-11-19


teddyking (author)2017-12-18

Could you please guide me to add more media control button. I want to use new trend mechanical switch keyboard but i can't live without these DELL magic keys. Please...

harshmmistry made it! (author)2016-12-31

This is a really useful project that I am keen to try out myself but I am not sure about the wiring connections between the digispark and rotary encoder.As shown in the figure I have a KY-040 encoder that has 5 pinouts.I have connected CLK to P0, DT to P1 and GND to GND but it does not work.Do help if possible.Thanks!

Kris S (author)harshmmistry2017-01-02

Use the pins on the encoder itself to determine how to connect it. The side with 2 pins is the switch--The side with 3 pins is the encoder. For the encoder, wire it just as in the crude diagram that I have in the instructable.

All you need to do is trace the connection on the encoder itself to the connection on the board you have that the encoder is attached to.

sokolik (author)Kris S2017-07-16

I love this project!

I'm using this code ( but after a pair of hours breaking my head with a KY-040 and a non-working mute button, I let here my experience if it helps someone: my KY-040 encoder has GND and "+" (5V) pins exchanged!!!! This pins are erroneusly printed on the board, so my current working pinout config is:

· CLK to D0

· DT to D2

· SW to D1

· "+" to GND

· GND to 5V

Thanks for the work!

WillSo (author)sokolik2017-11-03

I've made this project with KY-040 rotary encoder, just some notes:
CLK to P0, DT to P2, SW to P1, "+" to 5V, GND - to GND

I had to modify the code and remove/comment out these lines:

// digitalWrite(PIN_ENCODER_A, HIGH);
// digitalWrite(PIN_ENCODER_B, HIGH);

Because KY-040 already has pull-up resistors on all three channels (CLK, DT, SW), without that I had erratic behaviour.
Also implemented switch, with three functions (click = pause/resume, doubleclick = next, hold = mute).
For switch, I adapted code from here

Switch presses did not register on Pin 1 at first. Because it has LED wired to it, i had to actually damage the LED for clicks to start registering. Be sure not to damage the Power LED instead.
Disclaimer: It's all up to you, I'm not responsible for you damaging equipment or burning the house in the process.

Xaos1990 (author)WillSo2017-11-21

Thanks for the help!

Would love to see your adapted code for the different switch functions. This is my first arduino project so i dunno what im looking at at the forum post you linked..

WillSo (author)Xaos19902017-11-22

All I can do is post my current code. Sorry, it's a bit untidy with leftover comments from experiments.


The part you are interested in is at/after line:

int b = checkButton();
This line calls function to check for pressed state, then I just check for b value for:
0 = nothing, 1 = single press, 2 = double press, 3 = hold, 4 = long hold.

Xaos1990 (author)WillSo2017-11-22

Thanks man!

Marmbo (author)2017-08-12

Unable to compile, I keep getting an error. Looked over the steps multiple times and everything seems fine. Error:

C:\Users\Marmbo\Documents\Arduino\sketch_aug12a\sketch_aug12a.ino:1:29: fatal error: TrinketHidCombo.h: No such file or directory

#include "TrinketHidCombo.h"


compilation terminated.

exit status 1
Error compiling for board Digispark (Default - 16.5mhz).
Invalid library found in C:\Users\Marmbo\Documents\Arduino\libraries\Adafruit-Trinket-USB-master: C:\Users\Marmbo\Documents\Arduino\libraries\Adafruit-Trinket-USB-master
Invalid library found in C:\Users\Marmbo\Documents\Arduino\libraries\Adafruit-Trinket-USB-master: C:\Users\Marmbo\Documents\Arduino\libraries\Adafruit-Trinket-USB-master

WillSo (author)Marmbo2017-11-03

I must be late. I think you have moved whole Trinket-USB-master folder into Arduino\libraries folder, you have to move one of the subfolders, specifically TrinketHidCombo folder from inside Trinket-USB-master.

Sektor7G made it! (author)2017-10-27

I had some issues with the code for a bit and I also received a defective board from amazon. Nevertheless, it turned out well. I used a vintage cigarette box to hold the parts and I got a little coily cord USB cable.Thank you Kris!

MrHaza (author)2017-04-23

Hi, great instructable! On the Arduino Software I get

'Invalid library found in

C:\Users\Harry\Documents\Arduino\libraries\Adafruit-Trinket-USB-master: C:\Users\Harry\Documents\Arduino\libraries\Adafruit-Trinket-USB-master'

Was wondering if you could shed any light on this or let me know what I'm doing wrong. Thanks.

Marmbo (author)MrHaza2017-08-13

I am having the same error, did you ever get this fixed and if yes, how so?

MrHaza made it! (author)Marmbo2017-09-23

Hi, sorry I factory reset my PC so had to remember how to do it again.

I had to extract the zip files inside the adafruit library folder and then also I copied them into the C:\Users\......\Documents\Arduino\libraries\ folder (As shown in pictures. Also it would not work for me if I used an external USB Hub, it had be a USB port in my PC.

Marmbo (author)MrHaza2017-09-23

Perfect, that worked! Thank you!

MrHaza (author)Marmbo2017-09-23

No problem, glad it worked! :)

davidr706 (author)2017-09-20

hey guys i wanted to know if this can work as a knob . it was one used as a volume knob and i just wanted to know is this can work and also can you show what pin is what

Luke Wilson (author)2017-06-09

I was directed here from this Thingiverse page ( ) and it has this page linked so I am going to favourite this instructable and use this comment as a link to myself if I want to get back to that page. The 3D model looks quite good so if anyone else wants a case for this Instructables project, this one should suffice but I'm sure there are many other good ones online or even some Instructables of how to make one or something. This comment isn't advertising or anything just a note to self, ignore it if you want. I can't wait to get the parts specified in this Instructable so I can try it out so thanks to Kris S for these instructions. :)

Kris S (author)Luke Wilson2017-06-10

Thank you!

FilipM34 made it! (author)2016-11-22
I made it. Just what i whant and need .Thank u
Kris S (author)FilipM342017-04-01


Bennek (author)FilipM342017-03-04

How did You connect and program button to use click to mute volume ?

HuyT54 (author)2017-04-01

Not sure if its the coding or the my hardware, but having the digispark wired exactly like adafruit's diagram. I still cannot get the click button to do anything.

Any ideas?

HuyT54 (author)2017-03-01

Instead of volume, can you make it control a media player?

Only keys I want are:
-Left arrow key: when rotated counter clockwise
-Right arrow key: when rotated clockwise
-Spacebar: when pressed

Kris S (author)HuyT542017-03-01

Yeah that'd be pretty easy. But I believe you'd need to use an arduino leonardo, (or pro micro)

All you need to do is use an encoder library, and map the rotations to a virtual keyboard emulated by the leonardo.

I haven't done it, so this is just speculation on my part.

Let me know if you are interested in trying it.

HuyT54 (author)Kris S2017-03-02

Ah damn I already ordered the same parts as your guide assuming it was just a change in the coding.

What's your thought on the size of the leonardo or pro micro though? I was hoping for something similar to the size of the digispark so that it can actually be placed inside a knob.

Kris S (author)HuyT542017-03-02

Just did a quick search and it seems that it is possible to use the digispark to emulate a keyboard.

Check this link:

Let me know if it is useful.


HuyT54 (author)Kris S2017-03-03

Awesome, will keep you updated on how it turns out.

Also I can't seem to get to that google link, sorry.

danzou1275 made it! (author)2017-01-05

Really nice instructable. Thanks "Kris S". And "OrC2" for the great idea. I have added a reset switch coz i too had to unplug/replug it every time i restarted my PC.

Kris S (author)danzou12752017-01-06

Always amazed at what I see people do. That's pretty freakin awesome, man!

LucasA47 made it! (author)2017-01-05

Really useful and work pretty well!!

Kris S (author)LucasA472017-01-05

Wow that's a really cool design! Isn't the round hole on the bottom of the thick lego the right size to fit onto the encoder where the knob goes?

LucasA47 (author)Kris S2017-01-06

Hi This is a LEGO 61485 Its fit perfect with potentiometers, encoders and many more, this hole is bigger than the normal stud hole, I have a bounch of than they are very usefull and you don't need damange the piece because they fit just right

JoshW61 (author)2016-03-09

Is there any chance that you could tell me more about how to wire this thing up?

I have everything set up, but I am very new to eletricals and I am not sure how it work

Do you have to solder the wires to the board? What was the green tray looking item that was present in the video? how do you connect the rotary encoder to the board?

Thanks, its a great project!

harshmmistry made it! (author)JoshW612016-12-31

If you have this kind of encoder then you can connect it using the figure attached

Kris S (author)JoshW612016-03-11

Just use the photo in part 3 to wire it. Yes, you must solder the connections--Unless you use a prototyping breadboard.

JoshW61 (author)Kris S2016-03-15


I had a problem with the Adurnio Development Environment, because it said that there was an error compiling for digispark (default 16.5 MHZ)

Any thoughts?

Kris S (author)JoshW612016-03-15

Two questions:

What board do you have selected in the Tools>Boards Menu?

What programmer do you have selected in the Tools>Programmer Menu?

JoshW61 (author)Kris S2016-03-16

The board that I am using is: Digispark (Default - 16.5mhz)

The programmer is AVRISP mkII, but I have also tried USBtinyISP

Thanks for any help!

Kris S (author)JoshW612016-03-16

Hmm. And have you followed the tutorial that I posted within this instructible?

JoshW61 (author)Kris S2016-03-16

too the best of my ability! this is my first time, so i followed it to the letter!

Kris S (author)JoshW612016-03-25

I'm not sure what to tell you. I havent used the digispark in a long time, so I can't rememebr how I troubleshooted it. Your best option would be to watch some videos on youtube to figure out how to upload to it.

Here is a good one:

About This Instructable



More by Kris S:Make Life Easier...Arduino Thermostat for Window AC Unit (On the cheap)Turn NES Cartridge into USB Phone Charger!
Add instructable to: