Organize and Share your Electronics the way you want. Sign-Up for a free account now. It takes only 30 seconds!

2048 on Arduino

2048 on Arduino

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?

score

Losing the game

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.

Nokia 5110 LCD

Nokia 5110 LCD

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.

Game_Boy_Advance

Game Boy Advance

Playstation Dual Shock Controller

Playstation Dual Shock Controller

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 .

Joystick

Joystick

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.

18650 Battery

18650 Battery

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.

Top Sch

Top PCB Schematic

Bottom Sch

Bottom PCB Schematic

Top

Top PCB Layout

PCB bottom

Bottom PCB Layout

Hardware Design

Hardware Design

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.

DSC08858

Ironing bottom PCB

Opps, Damages

Opps, Damages

DSC08860

Ironing Top PCB

DSC08861

Not again!!

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.

DSC08864

After etching process

DSC08865

After removing the toner layer

DSC08866

Removed toner layer

DSC08868

Both of the PCB, ready to be drilled

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.

Top Layer Silkscreen

Top Layer Silkscreen

Bottom Layer Silkscreen

Bottom Layer Silkscreen

Bottom PCB

Bottom PCB

Top PCB

Top PCB

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).

 

Top PCB

Top PCB

Bottom PCB

Bottom PCB

Nokia 5110 LCD

Nokia 5110 LCD

Joystick

Joystick

Tact switches button

Tact switches button

Combined PCB

Combined PCB

Side View

Side View

Game Console

Game Console

2048 on Arduino Game Console

2048 on Arduino Game Console

2048 Gameplay

2048 Gameplay

Game Over

Game Over

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







 

More Articles to Read

An Arduino round word clock
An Arduino round word clock
The Sandwich-o-Matic will make your lunch automatically
The Sandwich-o-Matic will make your lunch automatically
An Arduino-controlled automated whiskey distillery
An Arduino-controlled automated whiskey distillery
The Rex800 looks like a dinosaur Terminator
The Rex800 looks like a dinosaur Terminator
Wrist thrusters let you fly through the water effortlessly
Wrist thrusters let you fly through the water effortlessly
Adjusting clock with alarm, hygrometer & thermometer on 1.8″ ST7735 display
Adjusting clock with alarm, hygrometer & thermometer on 1.8″ ST7735 display
Adding an “extra sense” with rangefinders
Adding an “extra sense” with rangefinders
This wireless game controller looks like a rug
This wireless game controller looks like a rug
How to run your ESP8266 for years on a battery
How to run your ESP8266 for years on a battery
Making beats on a tiny Arduino DJ controller
Making beats on a tiny Arduino DJ controller
This Arduino machine will judge how sick your ollies are
This Arduino machine will judge how sick your ollies are
Turn an old payphone into a boombox for ’90s hits
Turn an old payphone into a boombox for ’90s hits
QuadBot is a 3D-printable walking robot for everyone
QuadBot is a 3D-printable walking robot for everyone
An Arduino tachometer for your older vehicle
An Arduino tachometer for your older vehicle
Harry Potter fans create a fully-functioning smart wand
Harry Potter fans create a fully-functioning smart wand
A 3D-printed lunar phase clock for your nightstand
A 3D-printed lunar phase clock for your nightstand
Create your own Red Dwarf Talkie Toaster replica
Create your own Red Dwarf Talkie Toaster replica
The Orbitalochka is a solar-powered satellite synth
The Orbitalochka is a solar-powered satellite synth
Building a “laser sky” effect generator with Arduino
Building a “laser sky” effect generator with Arduino
Teslapathic! Hackers build a brain-controlled Tesla
Teslapathic! Hackers build a brain-controlled Tesla

Top


Shares