Step 5: Wiring

With all of the components securely fitted inside the enclosure, it's time to work out what needs to be wired where.

The ATMega328 chip used on the Arduino contains internal pull-up resistors, so we won't need to wire individual resistors for each of the arcade buttons. This greatly simplifies the controller wiring. So all that needs to be done to wire the arcade buttons is to solder one leg to ground, and connect the other leg to one of the digital inputs on the Arduino board.

That said, pin 13 can not be used as a digital input with the internal pull-up resistor. See the pullup resistors section in the Digital Pins article on the Arduino website for the reasons why. For this pin we'll be using an external pull-down resistor. If you're unsure what a pull-up/pull-down resistor does, check out this great tutorial on ladyada.net .

Wiring the potentiometers requires a ground wire, a wire to the one of the Arduino analogue inputs, and a third +5V wire. As the potentiometer is rotated or adjusted, the resistance of the potentiometer changes between the ground and +5V wire. According to Ohm's law, voltage = current*resistance, so with a constant input current and a variable input resistance, the output voltage will be variable. It's this variable voltage that the Arduino reads on the analogue pins.

The attached wiring diagram (created with the great Fritzing software) shows how to wire up each of the components to the Arduino board. The black wire represents ground, the red wire represents +5V, the purple and orange wires are digital inputs to the Arduino, and the blue and green wires are analogue inputs to the Arduino. Note that the ground wires and +5V wires have been bridged between the buttons and potentiometers.

Before proceeding to the next step you may find it helpful to print out a copy of the wiring diagram to refer to whilst you solder.
<p>Hey, great project. helped my big time. How about multiplexing? i would like to use uno or leonardo board but i want 16 buttons. So could someone say some advice about the multiplexing or just use the mega or tensy ++?</p>
<p>HEY GREAT PROJECT; just what I was looking for. Has anyone tried to use it with MAC?</p>
<p>Hi, I'm thinking of switching the Arduino board for the Teensy 2.0. Would I have to desolder the pull-down resistor on pin13 or could I potentially just leave it there?</p><p><br>Also, would I need to skip pins D2 (RX) &amp; D3 (TX) if the teensy isn't using serial communication? I was planning to wire it like this:</p>
<p>Hi thanks for your instructable! Everything is going well but I was just wondering if it was possible to setup the pushbuttons to be used as a piano keyboard? Like with a DAW or something?</p>
<p>By default, it is set up to do exactly that. The first button plays C, the second plays C#, the third plays D, and so on. :)</p>
<p>Omg got it, thanks! Is there anyway to remap the buttons so it starts on C3, followed by C#3, D3...? Also, I know the layout of the buttons follow the Midi Fighter's bottom to top order but is there a way to change it so it goes from top to bottom? Thanks so much for your help! I really appreciate it (:<br>I'm loving the controller!</p>
<p>Don't worry I found it! For anyone who wants to know, I replaced lines 159 to 178 with this:<br><br>#else</p><p> #define MIDI_CHANNEL 1</p><p> // First note, starting from upper left button</p><p> #define NOTE NOTE_C2</p><p> // This pin order corresponds to the top left button being zero, increasing by one as we move from left to right, top to bottom</p><p> // 0 1 2 3</p><p> // 4 5 6 7</p><p> // 8 9 10 11</p><p> // This array size must match NUM_DI above.</p><p> #if defined(ARDUINO_MEGA)</p><p> #define DIGITAL_PIN_ORDER 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53</p><p> #elif defined(TEENSY_PLUS_PLUS)</p><p> #define DIGITAL_PIN_ORDER 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37</p><p> #elif defined(TEENSY_2)</p><p> #define DIGITAL_PIN_ORDER 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12</p><p> #elif defined(TEENSY_PLUS_PLUS_2)</p><p> #define DIGITAL_PIN_ORDER 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37</p><p> #else</p><p> #define DIGITAL_PIN_ORDER 10, 11, 12, 13, 6, 7, 8, 9, 2, 3, 4, 5 </p><p>#endif<br><br><br></p>
<p>Great project you have here, it's just perfect</p><p>I made my own with just 8 pots instead of all the sliders and buttons; they all work fine except one, which gives a &quot;MIDI feedback shortcut&quot; error, and says not to connect the in and out to the same port. Oddly this only seems to happen with the one port. Any ideas?</p>
<p>Actually it sometimes works, but I have to use LoopBe30 and route it through 2 different ports with HairlessMIDI (instead of MIDI Yoke since Windows 8)</p><p>IDK what's up with that</p>
Do the push buttons need to be momentary or lock? <br>
<p>somebody help me please... i have arduino micro, can i use it as Midi controller??? i'm new on this community... please help me...</p><p>the circuit diagram also...</p>
<p>Hello such , I am Argentine and I'm doing the midi controller . USE sorry for translators .<br>My problem is this , I can not load the program to Arduino entiedo Not For Long . I hope your help. thousand thanks</p>
<p>I want to use only 16 buttons, as I do?</p>
<p>for arduino nano is necessary to modify the code ? that's ok?:</p><p>#if defined(__AVR_ATmega328__) || defined(__AVR_ATmega328__)</p><p>#define ARDUINO_NANO</p><p>#elif defined(__AVR_ATmega328P__)</p><p>#if defined(ARDUINO_NANO)</p><p> // Number of digital inputs. Can be anywhere from 0 to 68.</p><p> #define NUM_DI 13</p><p> // Number of analogue inputs. Can be anywhere from 0 to 16.</p><p> #define NUM_AI 8</p>
<p>Help me ! when i run the code i get this error <br>'PIN_D6' was not declared in this scope</p>
<p>It's been a few months since this was asked so I doubt you still need help. For others like me who might also run into this issue, I was able fix this by making some changes to the code(just a heads up, very minimal programming experience). Basically, seems like the code was detecting my leonardo as a teensy or something so I commented out the teensy #defines at the top:</p><p>#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)</p><p>#define ARDUINO_MEGA</p><p>//#elif defined(__AVR_AT90USB646__)</p><p>//#define TEENSY_PLUS_PLUS</p><p>//#elif defined(__AVR_ATmega32U4__)</p><p>//#define TEENSY_2</p><p>//#elif defined(__AVR_AT90USB1286__)</p><p>//#define TEENSY_PLUS_PLUS_2</p><p>#else</p><p>#define ARDUINO</p><p>#endif</p>
if i wanted to change the code so that the digital buttons sent a simple on/off signal instead of playing a note how could i do that
<p>yes, how do I do this? Apparently it is not possible through Ableton so it probably needs to be programmed in. </p>
<p>Hi, thanks for your instructable, it's great! Can you explain more about the LUFA library and how to make a true USB MIDI controller?</p>
<p>hey , is it possible to make a controller with two faders , 8 knobs?</p>
<p>Great instructable. I'm having some trouble with the slide pot. It believe I wired everything correctly but when I map the controller manually in Ableton and test out the slider, it has a very jumpy rise. Like moving the knob a centimeter would make the volume jump from the bottom and red line. But when I test the same thing on the rotary pot, it has a very smooth rise and fall. Why is this? I can't figure it out and I don't think I burned the pots because I was very careful when soldering and testing the resistance every time. Help please!</p>
<p>I had this issue and that was because how we should wire it and how the resistors are labelled are different ( and sometimes wrong) so just swap where the wires are going on the slide pot until it works :)<br><br>Thats how I fixed it haha</p>
<p>One of your pots might be logarythmic, and the other is probably linear. They have different resistance curves. Otherwise, the slider might have dirty contacts.</p>
<p>The pot is linear so how do i fix a dirty contact? or should i replace?</p>
Hi, i'm using only 12 buttons. Do I need to change the code or can i still use the same?<br><br>And, on Serial MIDI Converter, the TX doesn't flash green. What's happening<br>Do you have any idea?
Hey dude/Dudette <br>No you dont need to change the code in any way!! <br>Thats whats so awesome about his code, it is fluid.. meaning you can have as many or as little as you feel you want!! with in reason :) <br> <br>As for the midi problem, do you have midi yoke installed?? <br>If not, look up &quot;MIDI Yoke&quot; on google, download and install <br>That is most likely your problem!!! <br> <br>Get back to me if it works or not!! <br>Cheers, hope it helps!!! <br>:)
<p>Hi everyone;</p><p>I have the same problem. The Tx doesn't flash green on the Serial_midi program. Only the Rx. However on my Arduino board The Tx is flashing but not the Rx. Thats very strange. </p><p>I didn't installed the Midi Yoke because i'm on Mac. So i'm using the IAC driver. </p><p>Also, i build my board with Arduino Uno. Could it be the reason why the code doesn't work? </p><p>Please help me guys!</p>
<p>Its been like 2 years since I've had a crack at this hahaha So I doubt I can help but I'll try<br><br>I occasionally encountered this problem and I fixed it by re flashing the software and making sure all of the connections work well&quot;<br><br>Like literally re-flashing the software fixes alot of bugs for me from when I was using it; otherwise maybe look for an updated tutorial?<br><br>Good luck :)</p>
<p>Hey, i have the same TX problem !? Have you been able to fix it? </p>
<p>Nice setup. Just wondering how would i go about making this with an arduino Mega 2560? Do i have to change a lot of the code? What digital inputs do i use?I want to be able to hook it up to my old organ instead of using the push buttons(each key has the 2 wires so i think that should work)This project comes closer than anything i have seen for what i need it for :)</p>
<p>I have built a similar midi controller with an atari joystick, pots and 5 toggle switches on Digital pin 3-7. The problem is that when using them to turn effects on in Ableton I flip up to turn the effect on, but have to flip down and up again to turn the effect off. What I want is to turn the toggle switch on/up to turn an effect on and turn the button off/down to turn the effect off. How can I change the code to work like this with my switches? Thanks for your help!</p>
<p>where is the code?</p>
<p>Good job !! could you share me your code please? david_spow@hotmail.com</p>
<p>What program are you using? And do you have any videos with screenshots? While this instructable may not be the place for it, I was curious about what technique you're using between the controller and the program to create the demo video.</p>
<p>what if we want use rotary encoders? i`m trying to change the code a little for make it capable of using some infinite scrolling, but didn't worked. Any clues? </p>
<p>Hey what if I wanted more sliders and knobs and less buttons? Thanks!</p>
<p>I can't seem to be able to find the correct sized enclosure. If anyone has a working URL that would be helpful. Thank you.</p>
<p>Hi! , I did it!, this is working with ARDUINO LEONARDO, to do works just add: <br></p><p>#define serial serial1</p><p>Also you must have the code clean of errors.</p><p>Cheers and thank you for this great project.</p>
<p>alegeno did you change the connections to or just the code , and did you add more inputs.</p>
where do you buy the 10k linear sliding potentiometer?
<p>Any chance to implement midi without usb? I need it to talk with my old gear with my old 168/328 arduino board&hellip;</p><p>Good work!</p>
<p>none of my buttons work... hmm... my potentiometers and sliders work just fine.. each time i checked the midi signal (using MidiPipe) the buttons only recognized as a random midi signal. Also as i open up the Arduino console, my computer pick up so many random noise. I'm happy already by just using the slider for the crossfader in my DJ software :D :D</p>
Many thanks for this great tutorial. My question: Do you think we can mix your code with the HIDUINO project and using midi.h instead of serial com, to transform our Arduino uno and Mega as UsbMidi devices?
Quite possibly, but I haven't really looked at HIDUINO so I don't know the details. The main structure in the code for polling the digital and analogue reads would still work, provided the functions (digitalRead and analogRead) still work, but the comms would obviously need to change from serial to usb midi.
Will try and give result here :-)
I've just 'cleaned' code (take out the teensy and arduino mega part), no other change, just flashed the HIDUINO firmware and it work!!!!!!!!!!
<p>Hi, i'm using a MEGA, every time i flash it Hiduino, the sketch ain't run anymore, any clue? thanks</p>
In fact , it works natively with HIDUINO, Testing it on a Mega 2560. <br> <br>Fraganator, this has to be the best patch i've seen, working with so much flexibility and without jitter or strange bounces, right from the zip to the &quot;upload&quot; button! Thanks!!
<p>someone tried to flash it hiduino?</p>
<p>a few pages back a guy said it worked perfectly! can't try my self because i have a seeeduino</p>

About This Instructable


732 favorites


More by fraganator: Arcade Button MIDI Controller
Add instructable to: