Introduction: 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 aliexpress.com for less than $2 USD

Lets get started!

Step 1: 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.

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: https://digistump.com/wiki/digispark/tutorials/con...

Once set up, go to: https://learn.adafruit.com/trinket-usb-volume-knob... 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.

Note:

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

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!

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!

Note:

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

into:

#define PIN_ENCODER_A 2

#define PIN_ENCODER_B 0

Remember to check out some of my other instructables!

Comments

author
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.

author
Marmbo (author)MrHaza2017-08-13

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

author
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

author
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!

IMG_20161231_184118120.jpgIMG_20161231_184419742.jpg
author
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.

author
sokolik (author)Kris S2017-07-16

I love this project!

I'm using this code (https://learn.adafruit.com/trinket-usb-volume-knob... 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!

author
Luke Wilson (author)2017-06-09

I was directed here from this Thingiverse page ( https://www.thingiverse.com/thing:2329074 ) 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. :)

author
Kris S (author)Luke Wilson2017-06-10

Thank you!

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

Awesome!

author
Bennek (author)FilipM342017-03-04

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

author
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?

author
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

author
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.

author
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.

author
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: https://digistump.com/board/index.php?topic=20.0

Let me know if it is useful.

Also: https://www.google.com/webhp?sourceid=chrome-insta...

author
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.

author
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.

P_20161231_144351.jpgP_20161231_144341.jpgP_20161231_144206.jpg
author
Kris S (author)danzou12752017-01-06

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

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

Really useful and work pretty well!!

IMG_20170105_213127.jpg
author
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?

author
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

author
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!

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

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

IMG_20161231_184118120.jpgIMG_20161231_184419742.jpg
author
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.

author
JoshW61 (author)Kris S2016-03-15

Thanks!

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?

author
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?

author
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!

author
Kris S (author)JoshW612016-03-16

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

author
JoshW61 (author)Kris S2016-03-16

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

author
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: https://www.youtube.com/watch?v=O1aLLBAChq4

author
AkashA27 (author)2016-12-09

in online i am getting 5 pin encoder does it will support

author
Kris S (author)AkashA272016-12-10

There should be 3 pins for the encoder, and two pins for a push button for mute--Totaling 5 pins :)

author
OrC2 made it! (author)2016-12-02

Nice guide easy to follow thanks! <3

400d8e08-1867-4825-b3e1-cfdf4c467af4.jpg5c1c295b-bf60-4752-bf64-28ecf1401ef3.jpg
author
Kris S (author)OrC22016-12-02

Wow! that is genius! I will do it like that too!

author
Bullfrogerwytsch. (author)2015-11-22

Cool beans!
I have a keyes rotary encoder module,.. And i tried using the inbuilt switch to see if i could use it to add the mute the way they do at adafruit.. But it just caused problems,.. Ill have to investigate further.. otherwise without the mute it works great.

author
Kris S (author)Bullfrogerwytsch.2015-11-27

Hmm, I didn't mention it in the tutorial, but mine uses mute as well and I have no problems.

Did you tie the button to 5v? the encoder is tied to ground, but the code is set up so that the button is actually tied to 5v to work.

author
bonelifer (author)Kris S2016-03-12

If I understand correctly, tie to Pin 1 and the 5volt pin for mute?

author
Kris S (author)bonelifer2016-03-12

I believe so, yes. There should be clues within the code as well.

author
wakandan (author)Kris S2016-11-22

Hi Chirs, can you upload the schematic of your complete design and the code as well? I tried doing what was said in the trinket's page, try tieing pin 1 to VCC (through a 10k) resistor but the mute key is not registered. Also I'm confused about the direction: if you tie pin 1 to VCC, when pushing pin 1 then it would have 0V, then doesn't that mean pin 1 is Active-LOW? If that's the case then the code won't work, because it's designed to work with PIN 1 being active-HIGH. Well I supposed that should be the case, doing this check (notice the checking if it's LOW logic) (if (!bit_is_set(TRINKET_PINx, PIN_ENCODER_SWITCH))) instead, but it still doesn't work. I'm not sure if there's something missing.

Btw in your video the mute button works as expected, but your instructable doesn't contain any mention to that. Would you like to update for a more complete version? Thanks

author
安陳 made it! (author)2016-10-02

I made it. thanks for your patience Kris S.

IMG_20161002_203223.jpg
author
安陳 made it! (author)安陳2016-10-24

I realized the project isnt done until I show the HTPC (home theatre pc) I built with the usb knob (right side of the picture) ... many thanks to Kris S. for the help. Now all I have to do is add some remote control feature and 2 liner OLED plus finishing paints.. :)

IMG_20161024_210759.jpg
author
Kris S (author)安陳2016-10-24

Thats awesome dude! You turned the project into something very iunteresting.

author
Kris S (author)安陳2016-10-24

Awesome! XD how did you get it to work?

author
安陳 (author)2016-08-02

hi does this work with "infinite turn knob" (does not have any start and end point) as well?

author
Kris S (author)安陳2016-08-02

Since it uses a rotary encoder instead of a potentiometer, it can turn endlessly. :)

Does that answer your question?

author
安陳 (author)Kris S2016-09-30

sorry, I realized instructables dont send notification for any responses. I JUST received my digispark from China and I have an infinite knob (pioneer XWZ 4286). Just like my initial question, I am not sure if the same code will work with my encoder since it is not a potentiometer.

author
Kris S (author)安陳2016-09-30

What I used is not a potentiometer. a potentiometer will not work for this project.

does the encoder you have use 3 pins?

author
安陳 (author)Kris S2016-10-01

yes it does have 3 pins... I dont think mine is a potentiometer... it doesnt act as a variable resistor when I tested it with an ohm meter. it does however act like an endless on off switch whenever I rotate the knob in any direction. it also turns the main LED of the digispark on and off when I turn the knob.

also I noticed that it heats up a lot (blistering hot) when the encoder is plugged in to the digispark..

IMG_20161002_034250.jpgIMG_20161002_033942.jpgIMG_20161002_033950.jpg
author
Kris S (author)安陳2016-10-02

There should be one common point and two switching pins. connect ground from the digispark to the common point (generally center pin) then connect the I/O pins to the switching pins.Sorry, I don't know anything about that encoder--I recommend you buy a new one; they are pretty cheap.