Introduction: PCB - Keypad/gamepad

About: We build a lot of projects... Hopefully, we'll bring more to Instructables soon.

Human interface devices (HIDs) are used by everyone multiple times every day. Actually, you probably used one to reach this document, and your fingers are most likely hovering over one right now. HIDs are anything we may use to interact with technology. They are more commonly known as a mouse, keyboard, keypad, controllers, and remotes. Here we set out to make a custom keypad. They keypad will be a universal build that can be used with computers as a gaming pad or with your very own projects as an interaction and input device.

Step 1: Gather the Tools

- Soldering Iron

- Solder

- Flux

- Solder Wick (optional)

- PC to load the code

- Autodesk EAGLE PCB design software

Step 2: Gather the Materials

Note that the quantities listed are for one keyboard PCB. You will need to adjust the quantity of parts if building more than 1 keyboard PCB. Also, the LEDs are optional. They will make the design look much more appealing. However the keyboard will work perfectly fine without them. If you choose not to place the LEDs on, the 25 1k Ohm resistors are also not needed.

The PCB BOM

25x 1k Ohm resistor, 1/4W

25x 3mm Green LED

5x 10k Ohm resistor, 1/4W

1x Teensy 2.0

25x Mx Cherry Switch

Female headers

Male headers

Step 3: Create the PCB Files With EAGLE

We will go through some of the steps to create the keyboard PCB. This step can be skipped if desired. The PCB files that were generated to have the boards made will be made available. However, this is a good exercise to go through and in doing so will be a good learning experience. In addition, if you wish to make any modifications or change the layout and board shape this step will be necessary.

Autodesk EAGLE PCB design software was used to create the Shake Light circuit boards. EAGLE is one of the most widely used PCB tools for hobbyists and professionals alike. A free version is offered which will allow you to make smaller 2 layer boards, and for a reasonable price, an upgrade can be purchased to make larger multilayer boards. OSH PARK, the board-house we will use to fabricate the PCBs, works very well with designs made in Eagle. There are many additional options available for you to have the boards made, but we will not go into that here.

The board was laid out to be 6”x4.25,” the board size was not a priority in this design, and it can be altered and even reduced if necessary. Additionally, it is possible to route the entire design on a 2-layer board with some careful route planning. Lastly, mounting holes were added to the PCB. In general, if size permits it is always good to add in the mounting hole. This gives you the flexibility to add stand-offs later or create an enclosure for the PCB to live in.

Step 4: New Project and Schematic Will Need to Be Created in EAGLE

First a new project and schematic will need to be created in EAGLE. This can be done after opening Eagle under the “File” menu in the top left corner.

Before moving on, I would like to note is that there is a grid available to turn on or off depending on your preference. I personally like the grid and usually have it on when putting schematics together. This can be done through the top tool bars.

If you click on the matrix looking button, the grid settings will be displayed, and you can choose to turn it on and change the parameters.

Step 5: Begin Placing Components Down

With a new schematic window open, we can begin placing components down. This can be done through the toolbar on the left-hand side of the screen. The icon looks like an arrow or op-amp with a + sign on it. Furthermore, by hovering your cursor over the icons, a short description of the button’s functionality will be displayed.

When selecting the “add components” button, a window will be displayed with all the installed libraries of parts. By default when installing Eagle, it will come with a large library of parts. In fact, all of the components used in this design are available by default in the standard EAGLE libraries.

Once you have found the component you would like to use click “OK, ” and you will be able to place it in the schematic. Once placed in the schematic it can be moved, copied, rotated, or deleted.

Step 6: Connecting Parts Together

Once all of the components are placed they need to be connected together. This is done by choosing the “net” selection along the toolbar on the left.

Try to keep your schematic neat and organized, it is good practice and will look more professional. It will also help if you need to go back and try to debug a problem. Your finished schematic should look somewhat like the image shown below. Notes are also good to place on the schematic, they will serve as good reminders later for things that may be easily forgotten.

I will also like to note a few additional points about the schematic. For the Teensy board, a custom footprint was not made for the part. Instead, the intent was to use 0.1” standard female headers to mount to the PCB and place the Teensy in the headers. This will allow us to avoid sacrificing the Teensy to this design only and will also protect the device itself by allowing us to insert it into the PCB without having to solder directly to the device’s pins.

Also, net names were used in the schematic above to keep the schematic clean. This can be done in Eagle by using the Name command along the left toolbar. Any two nets with the same name are considered a connected net.

Step 7: Arrange the Components

Arrange the components on the board to resemble the arrangement in the schematic if possible. Depending upon space constraints or desired board shapes and dimensions this may not be possible. For this specific project, we did not have any space constraints and went with the more common rectangular board outline. Shown below is the layout, fully placed and routed. We will not go into the details on the steps of the layout as there are many thorough details on this that can be found online.

We also added ground floods to the top and bottom layer to cover fill in the empty space with no routes. This can be done through the polygon tool in EAGLE. Shown below is the PCB with the Ground fills added in.

Step 8: Generate Gerber Files for the Board-house

Go to the OSH PARK CAM jobs page to download the 2-layer cam file. Note that you will download different files for different versions of Eagle.

Click the CAM processor icon.

Within the CAM processor window, click File -> Open -> Job… and then navigate to the cam file. Click on it to load it. Then click the “Process Job” button.

With the OSH PARK cam file loaded, the CAM Processor window will look like this. Unless you specify otherwise, EAGLE will put the Gerber fills it generates in a default location. This can be less than ideal because it the save location may not be obvious, and the Gerbers may be mixed with other files. Sorting the Gerbers from the other files at a location can be a real pain.

To save yourself a bit of effort, you can specify a save location for the Gerbers by clicking the “File” button pointed at by the red arrow. You will have to do this for each tab within the CAM window.

Finally, to generate the Gerber files, click the “Process Job” button.

Attached to this step are the PCB design files.

Step 9: Order the PCBs From a Board-house

You could go anywhere to get your boards made, but we prefer OSH PARK. Their prices are hard to beat and the lead times, while not the fastest, are very reasonable. All you have to do is ZIP up the Gerber files, and upload them to the OSH PARK upload page.

Pictures are PCBs from Osh Park.

Step 10: Populate the PCBs With Components

Get the soldering iron heated up and ready to go. Some soldering iron’s have a variable temperature setting, this can be somewhat confusing for people new to soldering. I personally like the soldering iron to be around 700 degrees Fahrenheit. This is pretty much hot enough to “get in and get out.” When an iron is placed on a pad for too long, it can cause the pad to lift off with the iron or partially become ripped up. It is best to avoid this at all cost as that can render a PCB useless and that would be the last thing you would want to happen. So once again, the iron should be set hot enough to melt the solder quickly without having to hold it to the pad for too long.

The best way to go about populating the PCBs is, to begin with the smallest components first. In this case, it is the diodes. We placed all diodes into the PCB and went around and soldered them all in one shot.

The next step is to get the Mx Cherry switches soldered down. This is best done doing one row at a time as shown below.

In this case tape was used to hold down one row of switches while we soldered them in. It is also a good idea to create a jig or fixture to hold the switches in place and keep them all straight and aligned until soldered in.

Shown above is the PCB, completed, with the exception of one row.

Step 11: Moving Forward and Creating the Code

Now that the keypad PCB is assembled and ready to go, the next step is programming the device to make it act as a HID. This can be done through a common technique known as keypad matrix scanning. This is commonly used to reduce the number of IO pins needed on an MCU when a large number of switches are used. In theory, one row is set high by the digital IO pins, and the MCU reads in each column. If a switch is pressed, the MCU will read in the high voltage set on the row. Knowing the row and column one can determine which key was pressed.

The Teensy also makes this process more convenient. The Teensy is Arduino compatible, meaning the Arduino IDE can be used to do all the programming. This is good since the Arduino has many resources and examples available online. One can even find a programming example of the keypad matrix scanning. In addition, what makes the Teensy the perfect choice for this project is that it that it is easily recognized by computers as a keyboard or mouse. Indeed, minimal effort is needed to make the device appear as a HID.

In conclusion, you will know have a keypad that can be used with your computer or for your own projects. A little programming will be needed to get the matrix scanning working. However, minimal effort will be needed to make it appear as a USB HID device to your computer. Happy keying!