The Arduino Leonardo is a very powerful board with some slight differences from the very popular Arduino UNO. The ATMega 32U4 is the main processor on the Leonardo. You can use this microcontroller for serial communications over USB. The Arduino Leonardo is a USB 2.0 device which uses USB COM drivers. Unlike the UNO which uses the 328P, this USB feature gives us the opportunity to input programmed button commands into Windows via the USB interface. You can program single button presses or a button combination using software.
I use this button panel for Farming Simulator 2019 but you can use it for any game/program or key command required.
- Arduino Leonardo (http://tiny.cc/wa30dz)
- · 10 x LED Square Momentary Push Buttons ( http://tiny.cc/2520dz )
- · 10k Resistor
- · 220Ω Resistor
- · 1 x 5mm LED
- · 5mm Plywood
- · 16mm Spade Drill Bit
- · Vinyl Wrap (I used Carbon Fibre style)
- · 1 x 12V Power Supply (Not Required if using 5V Switches)
- · Wire
- · Soldering Station
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: The Design
I wanted to be able to use an array of buttons for my simulator games that had a visual display of the function rather than having to remember keybinds and key combinations. This design is simple in layout and very easy to replicate. I wanted to make a board that was 5 buttons wide and 2 buttons tall, a total of 10 buttons in all.
The buttons are equally spaced across the plan with plenty of room for fingers and labels.
I first made the design in Fusion 360 using the drawing feature to create a cutting template for the plywood. This gave me an accurate 1:1 scale drawing to use as a guide.
Step 2: The Build
I cut the plywood to size. TIP: Use masking tape on the cutlines to reduce tearing of the wood
The next stage is to drill out the holes, for the switches listed above you will need a 16mm Spade Drill Bit and a 6mm drill bit for the LED. If you are careful, you can drill the holes without much blowout. TIP: I used a small piece of MDF as backer to drill through so the holes came out clean with no tearing in the wood
This stage is optional but you can choose to vinyl wrap the wood to make the board more aesthetically pleasing, you can also paint it.
In this version, I used carbon fibre style vinyl wrap to make it look like a high end dashboard. TIP: Make sure the board is completely dust free and dry before applying the vinyl. I used a little IPA to clean the board and compressed air. Dust will make the vinyl uneven when applying.
Use a sharp knife to cut out the holes in the vinyl. These don’t need to be perfect as the buttons cover the edges of the holes.
The next stage is to populate all the holes with the buttons, the base of the button unscrews and you can tighten the button to the board from the back side.
This is how it should look once all the buttons are populated. Make sure the buttons are straight and level. I used a metal shroud around the LED to make it look more finished.
Step 3: The Wiring
The wiring part is simple and straight forward. The LED switches have 5 pins, 2 are marked LED which connect to the LED light in the button. There is a COMMON pin, a NORMALLY OPEN and a NORMALLY CLOSED pin.
I used 12V Panel Switches in this build but 5V Panel Switches are available, I would recommend using 5V to be compatible with the Arduino.
Connecting each terminal is simple:
· 12V + to Power Supply +
· LED Ground to Power Supply Ground
· 5mm LED connect to 5V on the Leonardo and have a 220ohm resistor in series for current limiting
· Connect all switch grounds together and solder a 10k resistor in series and put in the GND header of the Arduino Leonardo
· Use the Normally Open (NO) pin as we want to make a connection whenever the button is pressed.
· Each NO Pin of the button is connected to a digital pin on the Arduino (Use Pins 2-13)
The wiring can get tedious, but I used the hook method and soldering the wires bare to the pins, looping from one connection to the next.
Step 4: The Code
The coding is very simple on this build. Using the Arduino
IDE you will need the following 2 libraries installing:
The loop uses a series of if and else statements to look at each button. Each button is held high by the microcontroller and goes low once the button is pressed.
You can change the keybind by changing the text in the brackets:
Once this is uploaded to the Arduino Leonardo, reset the Leonardo and plug the USB cable into any free port on the computer. You can test the function of the buttons by using a keyboard tester program
Step 5: Final Product
I used inkjet printable acteate to print the label caps. The top of the button can be prised off and the acetate can be placed in between the button cap and stem. I also used a label maker to print the text above the label.
If you have any questions on the build, drop me a comment and I'll be happy to answer