PCB Handheld With Arduino (With an Option to Go Wireless!)
by Teemu Laurila in Circuits > Arduino
1032 Views, 4 Favorites, 0 Comments
PCB Handheld With Arduino (With an Option to Go Wireless!)
Update 28.1.2019
I'm currently working on the next version of this handheld. You can follow the project on my YouTube channel or Twitter.
Warning! I found a mistake in the PCB layout. The left and up buttons are connected to analog only pins. I fixed that by adding two pullup-resistors to the two inputs. That's not the perfect solution but it works.
I designed a PCB for a handheld that is based on the ATmega328P-AU microcontroller (same as in the Arduino Nano), SSD1306 OLED display and some buttons. I also added an option to add the NRF24L01+ radio module for multiplayer games. You could also use this handheld as a wireless controller. I've made wireless controllers before and even have one Instructables about them. All you would need would be an Arduino Leonardo or Pro Micro.
The handheld is completely open source. All of the source code is free to use as well as the PCB design. I also started coding an open source tile-based game engine for the console. At the moment everything works except the physics engine has some issues with high accelerations. That's just because the physics engine is running frame by frame at the same speed as the drawing function. The physics engine should have so called microstepping (moving one pixel at the time checking if there is a collision), but I still need to work on it.
As you can see from the picture, I haven't received the SMD parts yet. I'm currently developing the code with a prototype.
I don't want to get a professional PCB. Can I still build this?
Of course. I made already a tutorial on how to build this console to a prototyping PCB with dotted copper. You can find the project here: https://www.instructables.com/id/Arduino-Based-Handheld-Game-Console/
Getting All of the Parts
First off you need all of the parts. You can order the PCB's from JLCPCB or some other site that uses Gerber files. Gerber files are used to describe the PCB for the manufacturer. They are just .ZIP files that contain every detail of the designed PCB.
Here is the link for the PCBs: https://easyeda.com/laurilateemu8/k-sikonsoli-oled
Here is a list of the components you will have to buy in order to get it working:
- ATmega328P (TQFP-32)
- 8 pcs 6 x 6 x 6 mm buttons
- 16 MHz crystal oscillator
- 2 pcs of 22 pF 0603 sized capacitor
- SSD1306 display with SPI-interface. (128 x 64, monochrome)
- Two 0603 10 kΩ resistors
Here is a list of the optional components:
- NRF24L01+
- AMSD1117-3.3 (3,3 V regulator for the NRF24L01+)
- 1206 680 nF capacitor (NRF24L01+ need a steady voltage to operate correctly.)
- 2 pcs 1206 led (if you want to flash some lights)
- 2 pcs of 0603 resistors for the leds
Assemble the Board
This will be a bit hard to describe since I haven't built any PCBs yet. I have no clue where the parts went, but I hope they would arrive soon.
As usually with soldering, use some sort of fume extractor and wash your hands after touching flux or solder. And be careful with the soldering iron. It will make severe burns if you touch it while it's at around 350 degrees Celsius. If you however get an injury from the soldering iron, use cold water to cool down the burnt spot.
If you have never soldered SMD parts, I highly recommend watching some tutorials from YouTube. The basic rule is to apply the solder to one pad, put the chip in place and solder the pin. Then just do the opposite side and if there's more pins do them. You can also use flux to help with the soldering process.
You will also need solder wick to be able to solder the microcontroller. Just flow the pins with solder and use solder wick to get the excess out.
Make sure that you solder the parts right way. Usually microcontrollers have a dot to indicate the first pin. Usually PCBs have also a dot to guide with the orientation.
For SMD parts you usually want to solder the small parts first. If you solder the headers first, you will probably hit them with the soldering iron and release some nasty gases. I can recommend this sequence from experience. You don't have to follow this list, but it's made with common sense:
- Capacitors
- LEDs and resistors for the leds (optional) [first you should solder the resistors]
- Regulator and microcontroller (Make sure that you put the MCU the right way! The dot should face the same way as the mark [white dot] on the PCB.)
- Crystal
- Buttons
- Headers (The header of the NRF24L01+ is just where your finger would rest, so I recommend using some wires to allow some flexibility for it.)
- Some wires for the battery. The main power is marked with VCC and GND. VCC should be around 3,6-6 volts. That voltage goes directly to the microcontroller, so make sure that you don't put too much voltage through it.
The Software
I've made a few games for this kind of platform over the years. You can find the old multi-game code from here (It's the one that is named mushroom_mcp_continued_v10_converted):
https://github.com/Teneppa/handheld_open_source
The open source engine can be found here (I used Visual Studio to code it so there are multiple weird files):
https://github.com/Teneppa/openTileEngine