I had think of making a game on Arduino quite a while. An idea strikes to my mind while I was playing a quite popular game which is available on apps and pc, 2048. 2048 is actually a game created by Gabriele Cirulli, aged 19, Itallian web developer. The objective of this game is to slide the tiles and combine them to create the tile of 2048. Source: Wiki
This game can be quite addictive and challenging which also makes me thought of how the game works. You can play the pc version at http://gabrielecirulli.github.io/2048/. Then I took some time to figure out the basic of idea of the game operation, so that I can make one on Arduino. Isn’t it cool to create it on Arduino and create a different playing platform?
For this project, I decided to make a game console for it, which is also part of my to-do-list before. But to create the user interface, it requires a display that able to show all the numbers yet small in size. Therefore I decided to use Nokia 5110 Graphic LCD. Nokia 5110 can be obtained at low price from China sellers. Nokia 5110 LCD is cheap and easy to use, you should consider of using it in your next project.
Some of the features of 5110 LCD:
– 84 x 48 pixels
– Size: 43.6mm x 43.1mm (WxH)
– Power supply voltage : 2.7-3.3V
– Data interface level: 2.7-3.3V
– Available either white or blue backlight
After deciding the display unit, I need to decide to use what kind of user interface. I wanted to create something with the combination of Gameboy Advance and Playstation Controller. My final idea is to replace the direction button of Gameboy Advance into Playstation Controller’s Joystick.
I obtained my joystick by hacking an unused Playstation controller and de-soldered it from the PCB. A joystick consists of 2 potentiometers which is used for 2 axis control and also a tact switch .
Besides of having the joystick as control, there are also four tact switches which is used for user inputs. Therefore, you can actually play 2048 on Arduino by either using joystick or buttons.
Then, I have included a buzzer for my game console which is used to notify the player when they combined one or more tiles.
As I mentioned before, everything is controlled by using an Arduino, for my case, a DIY Arduino. I am using Atmega328P running with Arduino Uno bootloader, 16Mhz.
Being a portable game console, I need a portable power source too. 9V battery might be the choice but it is unable to provide sufficient current and one time use only. Furthermore, I am using LM7805 which has 2V dropout voltage. When the 9V battery reaches below 7V, I have to replace a new one. Therefore, the solution I made is using two 18650 batteries, each providing around 3.7V. The advantage of using 18650 battery is they are rechargeable, a good source of portable power supply.
After explaining all the electronics part, let me explain the design on my game console. I decided to make two PCBs where one is for the user interface, the other one is microcontroller and power supply board. I designed the PCB using Eagle Cadsoft.
I will show and explain some of the photos I have taken during the making of PCB. I made the PCB by using Toner Transfer Paper. This allows me to make nets that are thin enough to pass between two IC’s pins. Toner Transfer Paper allows you to make a neat and complex circuit in a short time. However, I was rushed at some time which cause some damages during the iron process. Luckily, the toner had been transferred, phew.
After ironing process, I removed the toner transfer paper and proceed with etching process. If you want to know more about the process, check out my previous article on DIY PCB.
Below are the final product after completing all the DIY PCB process. Note that the PCB on image below is different from the above images. They are the second revision of my PCB. I did some mistakes on first revision such as missing net, wrong footprint for on/off switch. The biggest mistake I had made on first revision is missing pull up resistor for Arduino reset pin. It causes the program to reset while the program was running.
Actually, I started everything on a breadboard but I did not take images on them while prototyping. So I can’t show you the images during prototyping process. However, I have a few video where I test my PCB whether they are working or not using the original circuit on breadboard.
Breadboard version 2048 on Arduino
If you noticed, there are still some bugs in breadboard version. But it has been fixed in the final version.
Testing the buttons on PCB
Running the Nokia 5110 LCD on PCB
I was glad that the PCB works, watching it displays the 2048 game.
Up until now I haven’t mentioned about the programming part of this project. Programming the 2048 is very challenging because I need to figure every steps and possibilities for the game. But I believe where there’s a will, there’s a way. What could possibly stop a maker from making (Hi-5 if you are a maker and agree with this!)? It took me around three to four days to complete programming the Arduino and another two days to complete the PCB (could have been one day if I did not make the silly mistakes mentioned above).
Last but not least, a video showing the game play of my 2048 on Arduino. Enjoy.
*Will try to come up with another video with explanation in the future. Stay tuned.
Overall, this was my first project to made on a PCB. I started with prototyping on breadboard, programming the algorithm and designing the hardware and PCB. I learnt a lot throughout the process and hope to create more new ideas in the future. Some future improvements that can be done are saving highscores or have more games on this game console.
Feel free to leave me a comment or suggestion.
Read more Here