
Media Control Knob
prusaprinters
<h4>Intro</h4> <p>Media Control Knob inspired by Mikolas Zuza design:<br/> <a href="https://blog.prusaprinters.org/3d-print-an-oversized-media-control-volume-knob-arduino-basics/">https://blog.prusaprinters.org/3d-print-an-oversized-media-control-volume-knob-arduino-basics/</a></p> <p>I've changed the enclosure, code and used digispark instead of arduino so it's hard to call it a remix.</p> <p>Because I've reached 100 subscribers on YouTube and I'm very happy about it you can win one of these, just enter the giveaway here:<br/> <a href="https://kingsumo.com/g/iwjfoi/3d-printed-media-control-knob-medyk3d-100-subs-on-youtube">https://kingsumo.com/g/iwjfoi/3d-printed-media-control-knob-medyk3d-100-subs-on-youtube</a></p> <h4>My video about this item:</h4> <p><a href="https://www.youtube.com/watch?v=acIH6Y_1LRc">youtube.com/watch?v=acIH6Y_1LRc</a></p> <h4>What it can do?</h4> <p>By default pressing the knob is play/pause button, rotating changes the volume, and rotating the knob with button pressed changes the track.<br/> You can modify the left() right() and click() functions to suit your needs.</p> <h4>BOM</h4> <p>Stuff I've used (affiliates links, you pay nothing extra, I get some change):<br/> Encoder ($ 0.5)<br/> <a href="http://s.click.aliexpress.com/e/_dSqXwoQ">http://s.click.aliexpress.com/e/\_dSqXwoQ</a></p> <p>Digispark - choose the blue one ($ 1.3)<br/> <a href="http://s.click.aliexpress.com/e/_dYKzAK2">http://s.click.aliexpress.com/e/\_dYKzAK2</a></p> <p>USB cable.<br/> 3D printed lower and upper cover - about 27 grams of filament (3 hours with 0.2 layer).</p> <h4>The code</h4> <p>How to configure Arduino IDE for Digispark:<br/> <a href="https://digistump.com/wiki/digispark/tutorials/connecting">https://digistump.com/wiki/digispark/tutorials/connecting</a><br/> Add Trinket USB Keyboard library:<br/> <a href="https://learn.adafruit.com/trinket-usb-volume-knob/code">https://learn.adafruit.com/trinket-usb-volume-knob/code</a></p> <p>Uploading the code is easy but first you need to follow the instructions from digisaprk on how to add it to arduino IDE if you haven't already.<br/> After installing all what's left is to hit upload button and plug the digisaprk using a USB cable.</p> <p>After a while the multimedia knob is ready to use.</p> <p>If you want to change the rotation direction just switch PIN_ENCODER_A and PIN_ENCODER_B in the code.</p> <h4>Assembly</h4> <p>You will need:<br/> wires, wire cutters, digispark, encoder, soldering iron, something to desolder pins from encoder, hot glue, a file, 3D printed parts, usb cable.</p> <p>First prepare the wires cut 5 pieces to about 2,5 cm(1inch) length and cover the end with solder.<br/> Desolder the pins from the encoder.<br/> Round over the edges of digispark with a file, be careful not to damage the USB socket.<br/> Now connect the encoder with the digispark in my case I'm using black wire for GND, red for 5V, these are really important, so be sure to connect them properly.<br/> The next three wires are:<br/> blue for switch,<br/> green and yellow for encoder A and B outputs. These are not super important you can always change them in the software.<br/> In any case there is the schematic if you need one.<br/> You need to remove the LED.</p> <p>It's a good idea to add something non slippery to the bottom so you can rotate the knob easily.<br/> Pure PLA just slides way to easy on the desk surface.</p> <h4>Source code</h4> <h3>include "TrinketHidCombo.h"</h3> <h3>define PIN_SWITCH 0</h3> <h3>define PIN_ENCODER_A 2</h3> <h3>define PIN_ENCODER_B 1</h3> <p>bool switchState = HIGH;<br/> bool encoderAState = HIGH;<br/> bool encoderBState = HIGH;<br/> bool previousSwitchState = HIGH;<br/> bool previousEncoderAState = HIGH;<br/> bool previousEncoderBState = HIGH;<br/> bool canClick = true;</p> <p>// the setup routine runs once when you press reset:<br/> void setup() {<br/> pinMode(PIN_SWITCH, INPUT);<br/> pinMode(PIN_ENCODER_A, INPUT);<br/> pinMode(PIN_ENCODER_B, INPUT);</p> <p>digitalWrite(PIN_SWITCH, HIGH);<br/> digitalWrite(PIN_ENCODER_A, HIGH);<br/> digitalWrite(PIN_ENCODER_B, HIGH);</p> <p>TrinketHidCombo.begin(); // start the USB device engine and enumerate</p> <p>encoderAState = digitalRead(PIN_ENCODER_A);<br/> encoderBState = digitalRead(PIN_ENCODER_B);<br/> previousSwitchState = switchState;<br/> previousEncoderAState = encoderAState;<br/> previousEncoderBState = encoderBState;<br/> }</p> <p>// the loop routine runs over and over again forever:<br/> void loop() {<br/> bool wasChanged = false;</p> <p>previousSwitchState = switchState;<br/> previousEncoderBState = encoderBState;<br/> previousEncoderAState = encoderAState;</p> <p>bool switchStateReading = digitalRead(PIN_SWITCH);<br/> bool encoderAStateReading = digitalRead(PIN_ENCODER_A);<br/> bool encoderBStateReading = digitalRead(PIN_ENCODER_B);</p> <p>delayMicroseconds(750);</p> <p>if(digitalRead(PIN_SWITCH) == switchStateReading && switchStateReading != switchState)<br/> {<br/> switchState = switchStateReading;<br/> wasChanged = true;<br/> if(switchState == LOW)<br/> {<br/> canClick = true;<br/> }<br/> }</p> <p>if(digitalRead(PIN_ENCODER_A) == encoderAStateReading && encoderAStateReading != encoderAState)<br/> {<br/> encoderAState = encoderAStateReading;<br/> wasChanged = true;<br/> }</p> <p>if(digitalRead(PIN_ENCODER_B) == encoderBStateReading && encoderBStateReading != encoderBState)<br/> {<br/> encoderBState = encoderBStateReading;<br/> wasChanged = true;<br/> }</p> <p>if(wasChanged == true)<br/> {<br/> if(encoderAState == LOW && encoderBState == LOW)<br/> {<br/> if(previousEncoderAState == HIGH && previousEncoderBState == LOW)<br/> left(switchState);<br/> if(previousEncoderAState == LOW && previousEncoderBState == HIGH)<br/> right(switchState);<br/> }</p> <pre><code>if(encoderAState == HIGH && encoderBState == HIGH) { if(previousEncoderAState == LOW && previousEncoderBState == HIGH) left(switchState); if(previousEncoderAState == HIGH && previousEncoderBState == LOW) right(switchState); } if(switchState == HIGH && previousSwitchState == LOW) click(); </code></pre> <p>}<br/> TrinketHidCombo.poll();<br/> delayMicroseconds(1000);<br/> }</p> <p>void left(bool switchState){<br/> canClick = false;<br/> if(switchState)<br/> TrinketHidCombo.pressMultimediaKey(MMKEY_VOL_DOWN);<br/> else<br/> TrinketHidCombo.pressMultimediaKey(MMKEY_SCAN_PREV_TRACK);<br/> }</p> <p>void right(bool switchState){<br/> canClick = false;<br/> if(switchState)<br/> TrinketHidCombo.pressMultimediaKey(MMKEY_VOL_UP);<br/> else<br/> TrinketHidCombo.pressMultimediaKey(MMKEY_SCAN_NEXT_TRACK);<br/> }</p> <p>void click(){<br/> if(canClick)<br/> TrinketHidCombo.pressMultimediaKey(MMKEY_PLAYPAUSE);//MMKEY_MUTE<br/> }</p> <h3>Print instructions</h3><p><strong>Rafts:</strong> No<br/> <strong>Supports:</strong> No<br/> <strong>Resolution:</strong> 0,2<br/> <strong>Infill:</strong> 30%<br/> <strong>Filament:</strong> [ Fiberlogy Fibersilk PLA ]White/Silver<br/> <strong>Notes:</strong></p> <p>You need to print:<br/> 1x LowerBodyBiggerHole_v4<br/> 1x UpperCoverBiggerSmooth_v4 or<br/> UpperCoverBiggerKnurling_v4 or<br/> UpperCoverBiggerVertCuts_v4<br/> Print them flat side facing down.</p>
With this file you will be able to print Media Control Knob with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on Media Control Knob.