3D print an oversized MEDIA CONTROL volume knob – Arduino basics
Articles Blog

3D print an oversized MEDIA CONTROL volume knob – Arduino basics

3D printing a volume knob, connecting an Arduino
to a rotary encoder and flashing a code to the Arduino. That’s in a nutshell what we’re going
to show you in this video. Let’s start with what you probably understand the best and that’s 3D printing. We’ve prepared a few different designs and
we have ready to print G-codes and model files at prusaprinters.org. You just have to pick your favorite
and print it. The circular dials are actually interchangeable
and fit all of the volume knob bodies, so you can mix and match. Ok next, let’s talk about how is the knob
going to work. We could physically route the audio signal
through the knob and use, for example, a potentiometer to adjust the volume. But that would unavoidably
degrade the signal a bit. Instead, our volume knob will behave very
much like a keyboard with media control keys. We’re going to send keystrokes to the operating
system, which will then forward the command to a running Youtube video, or an app like
Spotify. And because we’re acting just like a keyboard,
this works on all Windows, Mac, and most Linux distributions. We need just 2 components! A rotary encoder and an Arduino Pro Micro. Actually, we’re going two different Pro Micro boards. An Original Arduino Pro Micro for prototyping and a smaller clone Pro Micro board that will
fit inside the volume knob for the final product. The rotary encoder is the same component that’s
under your 3D printer’s control knob. It spins. Indefinitely! Which is awesome, no need to handle what happens,
when you reach the end. And it also clicks! When you press it, the rotary encoder behaves
just like a button. This opens up a surprising amount of control because you can map different actions to single click, double click or long press. And the Arduino? If you never used it before, don’t worry, for a second we’re going to pretend that everyone watching this video has no experience
with Arduino boards what so ever. Arduino is an open-source project responsible
for a variety of single board microcontrollers. Think of them as small computers. These boards are equipped with analog and
digital input and output pins, so you can interact with the world. There are many different types of Arduino
boards. Big ones, like the Arduino UNO, which are
great for prototyping. Or really small ones like the Arduino Nano
or Pro Micro. All Arduinos have a basic keyboard emulation
built-in. However, for our application, there is a crucial
difference between them. Unlike the Arduino Uno or Nano, which use
USB to Serial adapter, the Arduino Pro Micro supports USB directly thanks to the ATmega32u4
microchip. This is really important! The media control keys won’t work on Arduino
Uno or Nano. Plus, as the name suggests, the Pro Micro
is really small and has a micro USB connector, so we’d want to use it anyway. Since we have only two components to connect
to each other, the wiring is really simple. Connect the pins labeled GND (ground) to GND
and plus to VCC. Then on the rotary encoder there are two pins
that handle the rotation, usually labeled CLK and DT. Connect them to analog inputs
labeled A0 and A1. Lastly, there’s the button pin labeled SW,
connect it to analog input A2. You can use these female-to-female jumper
wires, which are ideal for prototyping. But once everything’s working, consider soldering
cables directly to the board. Grab a new Arduino without
pins soldered to it. Then you can put cables through the tiny holes,
where the pins would normally be, which makes the soldering job way easier
and the resulting size is also smaller. And you can keep the Pro Micro with the pins
attached for prototyping of your next project. Now it’s time to program the Arduino. Unlike, for example, 3D printer firmware, it’s not common to share pre-compiled code for an Arduino. Instead, we share the source code, so that anyone can make changes
to the code or choose a different target board. To compile and upload the code, we need Arduino
IDE, which is a free software and the download link is in the video description. Once you download, install and open it, download
the source code for the oversized knob. Then in Arduino IDE choose File – Open and
select the downloaded file. The code uses a custom library “HID-project” that has definitions of the media control keys and makes the code easier to understand. We’ll have to import the library. In the top toolbar select Tools – Manage Libraries. In the new window, type in “HID-project”
into the search bar. Click on the HID-project by Nicohood and select
Install. Another library, actually two of them, is
for reading the data from the rotary encoder. The first one is called “TimerOne” and
you can install it exactly the same way, as we just installed the HID project library. The last library we need is called “ClickEncoder”
and has to be installed manually. But that’s still really easy. Download the ClickEncoder library using the
green button Clone or download – Download ZIP. Then in Arduino IDE Select Sketch – Include library –
Add .ZIP library and choose the file you just downloaded. Almost there, now we just have to tell Arduino
IDE which board we’re using and to which USB/Serial port it should upload the code. Select Tools – Board and select the Arduino/Genuino
Micro. Connect your Arduino Pro Micro to your computer. Then Select Tools – Port. And here You should see COM1 and COM – some
number (Arduino/Genuino Micro). Select the Arduino/Genuino Micro Now we’re ready to hit the Upload button That’s it! Once the upload finishes you can test your
volume knob. If rotating it changes the volume in
the wrong direction, either switch the two cables that handle the rotation (CLK and DT). Or switch the line that says VOLUME_UP to VOLUME_DOWN and vice versa. Now just put everything inside the 3D printed
enclosure and enjoy the convenient media control. The default behavior is single-click for play/pause
and double-click for skipping to the next song. So how do you like this project? Would you like to see more tutorials with Arduino? Also most of you are still not subscribed, you should do something about it! Let us know in the comments if you have a cool idea for next project. And as always happy printing!

100 thoughts on “3D print an oversized MEDIA CONTROL volume knob – Arduino basics

  1. Can you map the button to change scroll wheel functionality? For example, one click to set the wheel to change volume, and two clicks to set the wheel to seek through a video.

  2. Nice ! I am trying to do the same but for controlling picoreplayer with Logitech Media server via WiFi. I didn't succeed for now 😅

  3. Love it! Like to see more projects of this nature and circuitpython boards. Maybe circuit playground express or ESP 32s

  4. Awesome! Would like to see that taken one step further using a bluetooth shield and maybe a powerbank or connected to a phone for power.

  5. Thanks – Cool tutorial. IDEA – What about a control box with 8-10 buttons / knobs to help with the most common features of Fusion 360 (e.g. knob to zoom in/out/reset, buttons to change view TOP/FRONT/RIGHT, button "E" to extrude, etc.)?

  6. The 3d model files at prusaprinters.org do not include a bottom plate for the base, like the one shown at 7:26. Please share a link to that file

  7. Just inspired me to finally build my own mechanical keyboard with a massive media knob built-in! Thanks Josef!

  8. Wow, even better than all the buttons is the fact that Prusa has invented teleportation!! Check the "stolen" spool of filament at 0:23

  9. I should see if I can manage this with a tiny STM32F030 that's like 0.3$ and is Soo tiny but the USB communication would suck since there's no Arduino

  10. I have built this about two years ago. Designed in SketchUp, printed on MK2 and assembled with Digispark, which is cheaper than pro micro and also smaller.

  11. I have did similar project with same encoder/switch module + OLED display + Bluetooth and MicroPython board (I do not like Arduino so much) amd use it like Google NEST 3 Thermostat. It looks very cool. Maybe I should make a video how to make it from the scratch.

  12. Great project. How about taking this a bit further and have a rotary encoder with a numeric keypad in one. This allows you to use it for CAD and video editing etc. Keep the content coming.

  13. Great idea please do more. I know I will have to watch this many times before I get it. Could you slow down, zoom in more, or both, thanks and keep them coming

  14. Hey Prusa Team
    Nice Video!
    Wath do you think about a special keyboard with short cuts for for example fusion 360?
    Greetings Erik

  15. Asking for other Project Ideas, what about your own Version of a 3D Connexion SpaceMouse based on arduino and an analog Stick / 4 axis Controller?

  16. So the bottom line is that by making this knob, the 3d Printing Nerd (or Thomas, or 3DMN…) will appear in my lab? uhm….

  17. I think 3D printer firmware should be open source, but it makes sense to close the source, with all the development effort that goes into it

  18. Using an sd card reader attached to the arduino, and a small speaker, would it be possible to turn the media nob into a media player?

  19. Can you link to the personalities that are in the intro? I know some of them but not all and they always deserve credit for all the awesome work they do.
    Love this project by the way, great write up!

  20. absolutely make more of this style video! The media controller at the end with 6 logo buttons should be the next one!!

  21. but…. its wired……. in 2019………

    I could do with this to add media buttons to the front of my pc
     #neverhappy lol

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top