loading

So you want to make a custom switch panel for Elite Dangerous, or some other game, huh? It's easier than you might think. I made one, and people like it... My original post on Reddit

If you've never used an Arduino or done any coding, this is a pretty good place to start. If you're not good at soldering now, you will be by the time you have finished. And if you've ever wanted to use the term 'matrix' in conversation without referring to an overrated Hollywood movie, then read on. You're in the right place.

First of all, there are a couple of fundamentals to understand before we continue. Have a cursory glance at these articles. Go there, understand what a matrix is, why it's useful here, and then come back..

http://pcbheaven.com/wikipages/How_Key_Matrices_Wo...

http://playground.arduino.cc/Code/Keypad

You're back? Good. It's not rocket surgery, is it?

First of all you're going to want to draw a layout. Feel free to use the layout provided if you intend to follow my design completely. If you want to customise or completely change the layout, you should use a geometrically accurate drawing application. I used Adobe Illustrator.

The layout will be wholly dependant on your choice of buttons and switches. Research every switch fully, order samples and measure everything before committing to laser cutting or engraving.

Ok lets talk about parts...

Step 1: Parts & Tools

For my controller, I sourced almost everything through eBay. Here are links to every part I used in the build.

7 x Momentary ON/OFF Toggle Switch. SPST = Spring return. Missile/Flip covers available. http://www.ebay.co.uk/itm/361793111625?_trksid=p2...

30 x Rectangular Illuminated Push-Button Switch. Removable covers. http://www.ebay.co.uk/itm/301995098756?_trksid=p2...

2 x ON/OFF/EMERGENCY STOP Switch Box. I could not find the same buttons individually. http://www.ebay.co.uk/itm/301995098756?_trksid=p2...

1 x Retex Sloped Console Enclosure (33020102). Panel size is 249 x 161 mm http://www.ebay.co.uk/itm/301995098756?_trksid=p2...

1 x Teensy 3.2 Programmable Microcontroller. Teensy is the only Arduino compatible PMC with native USB-HID that I know of. http://www.ebay.co.uk/itm/161870504500?_trksid=p2...

1 x 5V - 12V Step-Up Module. This is to power the LEDs, which in these particular switches are 12V. More on this later. http://www.ebay.co.uk/itm/161870504500?_trksid=p2...

1 x 220 Ohm Resistor. This is to regulate current through the matrix. How this works is actually a mystery to me.

1 x USB-B Panel Mount Socket. To attach to the rear of the unit.

1 x USB-A to USB-B Cable. To cable to the PC.

1 x USB-MINI to USB-A Cable. To link the Teensy with the panel mount socket.

1 x Custom Engraved Front Panel. I recommend against hand drilling the front panel.

All of the above parts cost me approximately £150. That includes the laser cutting and engraving. There are many reasons why I went to a professional engraver. The accuracy of the cutting is important due to the close proximity of the buttons to one another. That weakens the panel and hand drilling would almost certainly break the plastic. The enclosure comes with a blank Aluminium panel, so feel free to hand drill that, but be prepared for a battle with button placement. Want aluminium laser/waterjet cut? Be prepared to pay for it. So I went to a professional, and he showed me a piece of Traffolyte. It's rigid, laminated, and it provides two colour engraving with lasers. Affordable and perfect for this job. Expect to pay more than the £50 that I paid though. I got a shady deal.

Now for the tools and consumables.

  • Wire
  • Cable Ties
  • Soldering Iron
  • Solder
  • Wire
  • Cutters
  • Screwdrivers
  • Printable transparency film/acetate

Depending on your choice of buttons, you might also need...

  • Drill
  • Super Glue
  • Hot Glue Gun
  • Dremel & Bits
  • Drill & Bits

Grab your parts and tools, and lets talk about labelling buttons...

Step 2: Button Assembly & Labelling

Some of your buttons will require assembly. In particular the illuminated or labelled ones. The rectangular buttons in my design come in 5 parts. Switch, LED module, button, plate, and cover. Button labels are inserted at this point so pay attention to orientation. We want all the buttons to be oriented the same way so that when we flip the board over, all of the contacts are nicely uniform, making soldering a lot easier.

Labelling buttons is super easy. Use your/my layout and add text within the boundaries of the buttons. Print this on transparency and cut to size. Slot each one into the relevant buttons and you're done.

Other buttons might require some modification in order to fit in the enclosure. You can see in the next step that the front edge of the enclosure has less clearance inside than the rear. I had to use a different contactor than the ones that came with the large round buttons, because the ones supplied were far too deep to fit inside. These were applied with super glue and hot glue for support. Be careful of this when ordering buttons. I would recommend something more like this: 22mm Stainless Push Button Switch

Step 3: Unit Assembly & Wiring

It's time to look under the old girl's dress. As you can see, the assembly of the unit itself is quite straightforward. Insert the buttons and screw them down securely. Make sure you're still considering the orientation. Don't attach the Teensy or step-up module to the plate yet. We need to solder those first.

Remember when I sent you away to read about matrices? This is where we use that knowledge. Look at the photo above. See the red wires? That's the button matrix. The blue wires are for the LEDs inside the buttons. The reason for using a matrix of buttons is simple. We will require far fewer pins on our Teensy. If all buttons were wired individually, we would need 40 pins, one for each button. By using a matrix of 6 rows and 8 columns, we can reduce that to 14 (6 + 8). Therefore a Teensy 3.1 or 3.2 will suffice.

I have provided a simplified drawing of the button matrix to help you understand how mine is connected, and where there are omissions from the matrix. You will need this to understand the code later on. Don't worry, it will all make sense soon.

Step 4: Soldering

Rule #1 of soldering - Do not be on fire.

Prepare your workspace. Make sure there are no flammable materials nearby. Have good ventilation and take breaks. Clean your tip regularly. Just the tip, mind. It's pretty arduous but very satisfying when complete. This is not a soldering tutorial, so I won't tell you how to do everything here. Just follow the schematic and prepare small lengths of wire to speed up the process. Multiple pins will require two wires to be soldered together. That is the most challenging part of the whole build.

I soldered pins onto my Teensy, and inserted it into a breadboard. However, I recommend soldering the 14 primary matrix wires directly to the Teensy, along with the power output to the LED step-up module.

This is also a good time to solder the 220 Ohm resistor in line with the first column wire. This can be seen on my breadboard above. I'm not sure why it needs it, but without it the matrix will not behave. Using a resistor prevents a whole row or column from being triggered by a single button press. Trust me, use one.

The LEDs are soldered together in parallel. This ensures that the same voltage is applied to all. However different colour LEDs have different current draws. Expect brightness uniformity issues with this design. Alternatively use 5V LEDs, but I could not find 5V LED modules for these particular buttons. Every single one would have to be de-soldered and re-soldered manually. Ain't nobody got time for that. So, a 12V step-up is necessary.

I lied to you earlier, for simplicity's sake. All of the button matrix wires are red. All except for the 8 main column wires. I made these blue so that it was clear to see which were for the rows, and which were for the columns.

One last point. Surely by now you have realised that the panel is upside-down. Therefore follow the drawings from left to right, but work from right to left.

It's time to talk about the code...

Step 5: The Code

I have provided the code that I am using in my CF-1 controller. Scroll through it in the Arduino editor software and read the comments in grey. If it all makes sense to you then great! If not, stick around. I'll go into a little more detail.

The first thing at the top is the inclusion of the Keypad library.

#include <Key.h>
#include <Keypad.h>

This is an off-the-shelf bit of code that guides the Teensy to understand our references to key presses and instructions. The Keypad library has a lot of built in functionality for things like press, hold, release and idle. We will only be using the press and release commands.

Then we define the rows and columns in our matrix, and a character to each of our desired button presses.

const byte ROWS = 6; // Six rows
const byte COLS = 8; // Eight columns
char keys[ROWS][COLS] = {
  {'0', '1', '2', '3', '4', '5', '6', '7'},
  {'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'},
  {'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N'},
  {'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V'},
  {'W', 'X', 'Y', 'Z', '[', ']', ';', '#'},
  {',', '.', '/', '`', '-', '=', '*', '+'},
};

This does not relate to the key that the PC will receive when buttons are pressed. You can see that there are numbers, followed by letters, followed by punctuation. Using the char variable restricts us to using a single character. So for 48 buttons, we need 48 different characters. This allows us to separate the code from the output, so editing the output is easier later on. The actual output keystrokes come later.

The next part is to define the pins that the matrix is connected to.

byte colPins[COLS] = { 0, 1, 2, 3, 4, 5, 6, 7 };
byte rowPins[ROWS] = { 14, 15, 16, 17, 18, 19, };

Now we start defining instructions.

if ( kpd.key[i].kchar == '0' ) // SRV TURRET
         switch (kpd.key[i].kstate) {
            case PRESSED:
              msg = " PRESSED.";
              Keyboard.press(KEY_T);
              break;
            case HOLD:
              msg = " HOLD.";
              break;
            case RELEASED:
              msg = " RELEASED.";
              Keyboard.release(KEY_T);
              break;
            case IDLE:
              msg = " IDLE.";
              break;
          }

My code loops indefinitely. It scans the keypad for changes, then ascertains whether it was a press or a release. Then it calls an instruction based on which key it was, what state it is now in, and outputs the corresponding key press, or release, to the PC via USB, just like a regular keyboard. When it's done that, it breaks the loop and starts again, scanning for more changes. You can press up to 10 buttons simultaneously.

These are the press and release commands.

Keyboard.press(KEY_?);
Keyboard.release(KEY_?);

If you want to edit the keystrokes, you might need this: https://www.pjrc.com/teensy/td_keyboard.html

Be aware that the USB keyboard output in the provided code, is based on my arbitrary and completely ass backwards as f**k control method. Please feel free to change the keystrokes to your own control method within this code. Or be as backwards as me. Your call. Don't change the keypad layout at the top though. That will cause all manner of hell for you. Edit the (KEY_?) within each set of instructions lower down in the code. They're all commented well.

Upload to the Teensy. https://www.pjrc.com/teensy/td_usage.html

Step 6: Final Assembly

We're on the home stretch. If you have followed the schematic correctly, and uploaded the code successfully, connecting the Teensy to a PC should light all of the LEDs and button presses should be sending a single keystroke to the PC. Just open a word processor and start hitting buttons. Do they correspond to the layout? If not, go back and check your matrix first. That's the easiest part to cock up.

If all is well, we can make the final USB connections and close the case. Take the USB parts and connect them all up. It is worth noting at this point that multiple in-line connectors and couplings can cause voltage drop and prevent the unit from operating. The way I have done it is merely a matter of resources. A better way would be to have a standard USB-MINI cable directly between the Teensy and the PC. You would need an appropriate cable gland for the rear of the unit, as opposed to a panel mount USB socket.

Step 7: Play Games

Congratulations! You have just made yourself a fully custom controller for your favourite game. Or a really disorientating keyboard. You choose.

Assign controls in the game the usual way.

<p>Please tell me this makes sense as a &quot;Matrix&quot;?</p>
Looks good to me. Rows, columns, resistor. Good luck with the build. You're definitely on the right tracks.
<p>Nice! All the hardware has been delivered.. Just really breaking my head over the code part.. sort of dead in the water atm after lot of days of trying to get my head around it.. but i WILL make this work :)</p><p>Mucho excited!!</p>
<p>Just as an idea.</p><p>Have you considered using this program so as to use to or more keyboards? Of course setting up and rewiring another keyboard as well.</p><p>software</p><p><a href="http://www.hidmacros.eu/whatisit.php" rel="nofollow">http://www.hidmacros.eu/whatisit.php<br></a></p><p>And for ease of use maybe this?</p><p>hardware</p><p><a href="http://www.desktopaviator.com/Products/Model_2040/" rel="nofollow">http://www.desktopaviator.com/Products/Model_2040/</a></p><p></p><p>Great work by the way :) Voted for you</p>
<p>The keyboard app is definitely useful for something. Thanks for bringing it to my attention. The USB boards you mentioned are alsu useful, but too big and too expensive for this project. The Teensy is a really cheap way to do it.</p>
<p>Ok thanks, I will keep that in mind for myself if I ever get to do this :)</p>
<p>Hi Matt, looks amazing. Well done Cmdr. 07</p><p>I had a similar <br>idea and have bought a Arduino Due. Now some free time and a steep <br>learning curve (I have no experience with programming at all) and maybe i<br> will be able to make something similar.</p>
Arduino UNO is where I started. You can't do this project so easily without a teensy though. UNO doesn't have onboard USB HID, so it's really complicated to get it to send USB keyboard strokes. You'll need a teensy eventually. Good luck Cmdr!
<p>You're not supposed to send keyboard strokes! You can use some libraries to simulate a joystick, you can have up to 50 buttons available and even some axises.</p>
<p>Why not? I see no good reason. In fact, Elite only has 2 variations for each control. So if I had my joystick, throttle, AND the CF-1 connected, I could not apply the same control to all three, if I programmed it as you suggest. Furthermore, I use VoiceAttack. Some of the controls are duplicated there with keystrokes. Also, while assigning commands in-game, if the controller is not connected, and you apply changes, a unique controller will lose all of its assignments. Unless it uses keystrokes. If I needed axis control, joystick config would be ideal. That will be useful for my cyclic and collective project for ArmA III.</p>
<p>Oh and by the way. CF-1 = Control Freak 1</p>
<p>I've done some Fritzing.<br>Is this right?</p>
Looks spot on to me, pal. Thanks for doing that. What's the app called?
<p><a href="http://fritzing.org" rel="nofollow">http://fritzing.org</a></p><p>Thanks for your inspiration!</p>
<p>Extremely good. Loved Elite Dangerous and this project is just plain awesome!</p>
Thanks, pal. Vote up in the Microcontroller contest if you think I deserve a prize.
<p>Oh My God! I owe you sir a beer! Been wanting to do something like this for years but never had the time to look into it. Thank you!</p>
I'll have a cloudy cider. Old Rosie or similar. Cheers!
<p>Awesome! Love it! Very pro looking. I would try and make it but I already made an small acrilic one some time ago ;) For Elite Dangerous too, and Oculus Rift. I would need more destop space too hehe.</p>
Very neat. I like the minimal design. Nice engraving too b
<p>Hi<br>What's the name of the Font ( typo ) u used?<br>Excellent work</p>
<p>http://www.dafont.com/pt/space-age.font</p>
<p>THX</p>
<p>can you upload a video of playing it</p>
<p>I can, and I should.</p>
<p>I'm not a gamer, but this is so cool! Well done.</p><p>For reference, regarding front panels, it's worth looking at waterslide decals. The Lazertran ones can even be baked onto aluminium: </p><p><a href="https://www.instructables.com/id/Making-a-durable-decal-on-metal-with-lazertran/" rel="nofollow">https://www.instructables.com/id/Making-a-durable-d...</a></p><p>(I found this because I want to make a panel, haven't tried it yet!)</p>
<p>I've never heard of Lasertran before. That's awesome!</p>
Thank you so much! <br>This is great. I have been looking for something just like this for Elite: Dangerous.<br>CMDR MrSurak if you want to get together in a wing or something.
<p>Cool idea!</p><p>I sometimes play OpenRA (a free &amp; open source RTS based on Westwood Studios' Command&amp;Conquer series), mostly in multiplayer, although I'm still far away from major leagues. The matches tend to be brutal and fast-paced, and one of the most common newbies' mistakes is relying on a mouse too much. Given that the game allows you to assign keys to nearly every in-game action (e.g. repair, deploy, attack-move, production tabs, go to radar event, fire a superweapon...), such a device could add to the gameplay greatly.</p>
<p>WOW! Awesome!</p><p>This is not cheap!</p>
<p>Looks awesome! I always wanted to do something like this for &quot;Babylon 5: I've Found Her&quot;. Unfortunately, the Starfury's control include a switch between combat and navigation mode which basically remaps the entire keyboard. So a lot of keys would have double functions. The task of accomodating the keys in a way that they work fine for both modes discouraged me before I made any real progress. My plan, however, was to dismantle an old keyboard and replace the contacts below the keys with the contacts in my custom keyboard.</p>
<p>Looks great, always wanted to do something like this. Thanks for the great instructable!</p>
<p>I'm having some trouble finding similar parts and buttons here in the US, any places other than eBay you might know of that would have them? This is my first project of this kind.</p>
<p>Start here and look around: http://www.digikey.com/product-detail/en/nkk-switches/YB25RKG01-2CF05-JB/360-3293-ND/2107389</p>
<p>If you don't mind to wait for couple of weeks, you can find almost everything from aliexpress (at very good prices) , here are some examples</p><p>Rectangular illuminated push button <a href="http://s.click.aliexpress.com/e/FujYvJU" rel="nofollow"> http://s.click.aliexpress.com/e/FujYvJU</a></p><p>toggle rocker switch <a href="http://s.click.aliexpress.com/e/y7qVR3N" rel="nofollow"> http://s.click.aliexpress.com/e/y7qVR3N</a></p><p>Emergency pushbutton station <a href="http://s.click.aliexpress.com/e/AAUrVNF" rel="nofollow"> http://s.click.aliexpress.com/e/AAUrVNF </a> </p>
<p>Nice one. The rectangular buttons you found are a lot bigger than mine, and not intended for printed inserts. It took me a long time to find the ones I wanted. I first saw them used in vehicle lighting controls at an old workplace. These are very similar: <a href="https://goo.gl/uy7jR6">https://goo.gl/uy7jR6</a></p><p>The circular buttons are used everywhere in door controls, crane controls, etc. The toggle switches are very generic.</p>
Digikey likely has everything. You could even search for 5volt LED, and skip the 12v regulator if you go that route(sorry I haven't worked with rhe teensy, but I think those are low voltage as well...) I have been wanting to do something similar to this as well, so this was a nice reminder. Now I need to throw together an enclosure design in tinkercad, and 3d print...
awesome project mate keep it up ?
<p>That's an awesome project! Great instructable :)</p>
Thank you! It's my first one.

About This Instructable

36,655views

504favorites

License:

Bio: Engineer, Designer, Technologist...
More by MattRHale:How To Make A Custom Control Panel for Elite Dangerous, or Any Other Game 
Add instructable to: