Arduino LCD Game

80,457

351

69

Posted in TechnologyElectronics

Introduction: Arduino LCD Game

Making a great many things is very easy with Arduino microcontrollers. This Instructable tells you how to create a simple 1-button video game made from a handful of parts in the Arduino Basic Kit from 123D Circuits. It is a side-scrolling jumping game. This serves as a good starting point for creating your own games from simple maker electronics.

Parts list (all can be found in the Arduino Basic Kit):

  • 1 x Arduino UNO
  • 1 x LCD screen (16 x 2 character)
  • 1 x Electronics breadboard
  • 1 x 220 Ω resistor
  • 1 x Pushbutton switch
  • Solid-core hookup wire
  • 1 x USB cable

Step 1: Assembling the Parts

The parts needed are shown in the picture above.
Start off with the Arduino unpowered. Do NOT plug in the USB cable. That will happen in a later step when it is time to program it and try the game out.

Use a long hookup wire to connect the 5V signal on the Arduino to the far left of the red row at the top of the breadboard.

Use a long hookup wire to connect the GND signal to the far left of the black (or blue on some breadboards) row at the top of the breadboard.

The LCD (Liquid Crystal Display) module has a 16-pin male header on the underside. Plug this into the breadboard as shown in the picture. All of the electronic signals that power and control the LCD go through this header.

These pins are (from left to right):

  1. GND - power ground signal
  2. VCC - positive power signal
  3. V0 - contrast adjust
  4. RS - register select
  5. R/W - read/write select
  6. E - operation enable signal
  7. DB0 - data bit 0 (not used here)
  8. DB1 - data bit 1 (not used here)
  9. DB2 - data bit 2 (not used here)
  10. DB3 - data bit 3 (not used here)
  11. DB4 - data bit 4
  12. DB5 - data bit 5
  13. DB6 - data bit 6
  14. DB7 - data bit 7
  15. LED+ - backlight LED positive
  16. LED- - backlight LED negative

Using short hookup wires, connect GND and LED- (pins 1 and 16) to the black row at the top.

Similarly, connect VCC (pin 2) to the red row at the top with a short hookup wire.

Bend the wire leads of the 220 Ω resistor (red-red-brown colored bands) and connect it between LED+ and the red row at the top of the breadboard.

Use longer hookup wires to make the remainder of the connections:

  • Connect DB7 to Arduino pin 3
  • Connect DB6 to Arduino pin 4
  • Connect DB5 to Arduino pin 5
  • Connect DB4 to Arduino pin 6
  • Connect E to Arduino pin 9
  • Connect R/W to Arduino pin 10 (or to black row at top of breadboard)
  • Connect RS to Arduino pin 11
  • Connect V0 to Arduino pin 12 (or to black row at top of breadboard)

Plug the pushbutton somewhere to the left of the LCD screen, straddling the channel running along the center of the breadboard (see picture above). Connect one of the top two pins of the button to the black row at the top of the breadboard using a short hookup wire. Connect the other pin at the top of the button to pin 2 of the Arduino.

Step 2: Programming the Arduino

At this point, you should be ready to program the Arduino and test it out.

Start by making sure that you have the Arduino software installed on your computer. Download the LCD_Game.ino file on this page to your computer and open it in the Arduino software. Make sure the board is set properly for programming (Tools → Board →Arduino Uno).

Connect the Arduino to your computer using the USB cable. This will provide power to the Arduino/game and allow you to upload your program to the Arduino.

At this point, the screen of the LCD display should light up.

Program the Arduino by selecting File → Upload (or press the right arrow button at the top of the Arduino software).

If all goes well, the LCD screen should now show the game start screen like in the picture above.

Step 3: Changing Things and Making an Arduino Game Shield

At this point you have everything working, so what more is there to do?

If you want to change the way the game works, or make a cool printed circuit board for this project that plugs directly onto the Arduino and replaces of all those messy wires, here's how to get started.

I developed this game entirely using the very cool (FREE!) online electronics simulator 123D Circuits. I actually had the game fully working and tested before ever taking the Arduino out of the kit. Here's the virtual circuit for the Arduino LCD game.

You can actually play the game right in your browser without ever having to put together any actual electronics ("Oh, now you tell me"). If you want to make any changes to the game, or explore what's going on, you can copy the virtual circuit using the "Duplicate Project" button. You can then edit the source code and try out changes right there. There's also a full-featured debugger where you can step through the program line-by-line and see what's going on!

If you are so inclined, you can also make a circuit board to nicely connect your electronics to the Arduino. The project has a "Download Gerber" button that will get you the files necessary to give to a printed circuit board (PCB) manufacturer to have a custom printed circuit board made. You can see what this PCB look like by clicking the "PCB View" button toward the upper right of the circuit. Here's some useful info on getting that PCB made.

Enjoy!

21 People Made This Project!

Recommendations

  • Make it Move Contest

    Make it Move Contest
  • Casting Contest

    Casting Contest
  • Woodworking Contest

    Woodworking Contest
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

69 Comments

the brightness is too much how should i reduce it.

can you post a better pinnout (cant really understand this one)

can i omit the resistor and replace it with a a potentiometer

can you add some images of what cable goes to what port (i am using the sparkfun redboard and am new to this. by the way, the fact that it is not arduino uno does not matter, it is the same board with a different look.)

I made your game a long while ago(its amazing by the way) and i remembered it a while ago and decided to improve it. I had a piezo and i wanted to add music to it. long story short i added music to it and i uploaded it. the music worked great, but the game.... not so much. the game works all right but the frame rates are about 50 frames per hour. i think i might have accedentally edited the speed of the game but have no idea how to fix it. one of you probably knows how to edit the speed of the game.

1 reply

How are you generating the music? Perhaps playing your notes is blocking the game from progressing at normal speed?

really cool one, thanks for the tutorial

somehow I managed to get over 395

İ am 10 years and I got 147 my dad got 256

Acil yardim edin arduino atinca programi boyle hata veriyor acil yardim edin

IMG-20161112-WA0033.jpeg
2 replies

abi hatanı copy edib at böyle göremedim.

Maalesef sorunu tamamen anlamıyorum. Ayrıca, Türkçe bilmiyorum. BareMinimum örnek programında olduğu gibi çok basit bir programı derleyebiliyor ve yükleyebiliyor musunuz?

Doesn't work for me. I checked the wiring 3 times and it didn't work anyway. The LCD turned on but it shown just a white line at the top. what can I do? Please help me.

WIN_20161226_131345.JPG
2 replies

I am getting the same line on the top

I've not encountered this particular problem. In the picture from the first person, it looks like the backlight resistor is not 220 ohms. It might be possible that the circuit is drawing too much current, so the LCD panel isn't able to properly initialize. Try removing the backlight resistor or that wire to ground, and see what happens after resetting the Arduino.

SO I CAN'T SAY I MADE IT!!!!