DIY ADVANCE PROJECT NO.02 (DINO RUN)

DINO RUN
BUILD • CODE • PLAY
Create Your Own Arduino-Powered Arcade Game!
Build a dinosaur run game using an Arduino Nano, where it jumps over cacti and collects coins with a joystick.

1. What You’re Building

A pocket-sized arcade game: a dinosaur that runs, jumps over cacti, and collects coins on a small LCD screen – all controlled by a joystick and powered by an Arduino. You’ll learn how the hardware talks to the code, and how the code makes a game feel fun.

Project goal: Build and program a mini arcade game using an Arduino Nano, an LCD screen, a joystick and a buzzer.

2. Meet the Kit – Components Required

Here are the main parts used to build the Dino Run game:

Component What it does
Arduino NanoThe brain – runs your code and controls everything else.
20×4 LCD ScreenThe eyes – 4 rows of 20 characters, like a tiny old-school TV.
JoystickThe hands – tells the Arduino which way you’re pushing, and detects button presses.
BuzzerThe voice – beeps for jumps, coins, crashes and wins.
EEPROM (built in)The memory that doesn’t forget – remembers your high score even when the power is off.

Note: EEPROM is built into the Arduino Nano, so it is not a separate external component.

Component Images

Arduino Nano

Arduino Nano

20x4 LCD Screen

20×4 LCD Screen

Joystick Module

Joystick

Buzzer

Buzzer

3. Wiring It Up, Step by Step

Wiring is just connecting wires between matching holes (called “pins”) so the parts can send messages to each other. Go slowly, one wire at a time, and it’s hard to get wrong!

Safety tip: Before you touch any wires, unplug the USB cable from the Arduino. It’s much safer to wire things up with the power off.

Step 1: Connect the LCD Screen (the eyes)

Your LCD module has 4 small pins on the back, usually labelled GND, VCC, SDA and SCL. Connect each one to the matching pin on the Arduino Nano:

  1. LCD’s GND pin → Arduino’s GND pin (any GND pin works).
  2. LCD’s VCC pin → Arduino’s 5V pin.
  3. LCD’s SDA pin → Arduino’s A4 pin.
  4. LCD’s SCL pin → Arduino’s A5 pin.

Tip: SDA and SCL are like a tiny 2-wire chat line the screen uses to talk to the Arduino. GND is short for “ground” – think of it as the return path that completes the circuit.

Step 2: Connect the Joystick (the hands)

Your joystick module has 5 pins: VCC, GND, VERT (sometimes called VRy), HORZ (sometimes called VRx), and SEL. Connect them like this:

  1. Joystick’s VCC pin → Arduino’s 5V pin.
  2. Joystick’s GND pin → Arduino’s GND pin.
  3. Joystick’s VERT pin → Arduino’s A1 pin (this is what makes the dino jump).
  4. Joystick’s HORZ pin → Arduino’s A0 pin (used for the menu).
  5. Joystick’s SEL pin → Arduino’s D2 pin (this is the button you click by pressing the stick down).

Step 3: Connect the Buzzer (the voice)

The buzzer has 2 legs – a longer one (+) and a shorter one (−). If yours isn’t marked, don’t worry; buzzers are forgiving.

  1. Buzzer’s + leg → Arduino’s D8 pin.
  2. Buzzer’s − leg → Arduino’s GND pin.

4. Circuit Diagram

Circuit Diagram

5. Uploading Your Code

Wiring is done – now let’s teach the Arduino what to do! This part happens on your computer, using free software.

Step 1: Install the Arduino IDE

The Arduino IDE is the free program you use to write and upload code. Visit arduino.cc/en/software, download the version for your computer (Windows, Mac or Linux), and install it like any other program.

Step 2: Install the LCD Library

A “library” is a bundle of code someone else already wrote, so you don’t have to write it yourself. Our LCD needs one:

  1. Open the Arduino IDE.
  2. Click Sketch → Include Library → Manage Libraries…
  3. In the search box, type: LiquidCrystal I2C.
  4. Find the one by Frank de Brabander and click Install.

Step 3: Plug In Your Arduino

Connect the Arduino Nano to your computer with a USB cable. Your computer may make a little sound when it notices the new device – that’s normal.

Step 4: Tell the IDE What Board You Have

  1. Click Tools → Board → Arduino AVR Boards → Arduino Nano.
  2. Click Tools → Processor. Pick ATmega328P. If uploading fails later, come back and try ATmega328P (Old Bootloader) instead – many budget Nano boards need this option.
  3. Click Tools → Port and choose the port that appears (it may be named something like COM3 or /dev/cu.usbserial-…). If nothing shows up, see the troubleshooting tip below.

Step 5: Open and Upload the Game

  1. Click File → Open and select your DinoGame.ino file.
  2. Click the checkmark (✓) button in the top-left to Verify – this checks your code for mistakes before uploading.
  3. Once it says “Done compiling”, click the arrow (→) button right next to it to Upload.
  4. Wait for “Done uploading” at the bottom of the window – your LCD screen should light up with the game!

Troubleshooting Tip

If you see “programmer is not responding,” go back to Tools → Processor and switch to “ATmega328P (Old Bootloader).” If no port shows up at all, your Nano clone probably needs a free CH340 USB driver. Search “CH340 driver” for your operating system, install it, then unplug and replug the USB cable.

6. How Dino Run Is Organized

setup(): runs ONCE when the Arduino turns on – it sets up the screen, sounds and loads your high score.

loop(): runs FOREVER – this is where the actual gameplay happens.

The game is always in one “state”: MENU, PLAYING, GAME OVER or VICTORY, like scenes in a play.

What happens during each game loop?

  1. Read the joystick.
  2. Move the dinosaur.
  3. Move the obstacles and coins.
  4. Maybe spawn something new.
  5. Check for collisions.
  6. Update the score and level.
  7. Redraw only the parts of the screen that changed.

7. Try It Yourself!

Open your copy of DinoGame.ino and try changing just ONE line at a time – save, upload and see what’s different:

1. Jump higher/longer: Find currentJumpDuration = 850; and make the number bigger.

2. Change the coin sound: Find sfxCoin() and change the numbers inside tone(...).

3. Give yourself a 4th life: Find lives = 3; in startGame() and change it to 4.

4. Start the game on Hard mode: Find selectedDifficulty = DIFF_EASY; and change it to DIFF_HARD;.

5. Write your own Game Over message: Edit the text inside lcd.print("GAME OVER!"); (keep it under 19 characters so it fits the screen!).

Remember: If something breaks, that’s totally normal – just undo your change and try again. That’s exactly how real programmers learn.

8. Sample Output

Sample Output

9. Level Up – Design Your Own Feature

Ready for something bigger? Try designing a Shield power-up – an item that makes the dino briefly invincible when collected.

  1. Pick a spare custom-character slot and design a 5×8 shield icon.
  2. Make it spawn the same way coins do – a timer, a random lane and a moving position.
  3. When collected, set a flag like shieldActive = true; and start a timer.
  4. Reuse the same pattern the game already uses to turn off invulnerability after getting hit.

Think like a game designer: This is exactly how real game features get built – take a big idea and break it into small pieces you’ve already seen work somewhere else in the code.

READY, SET, DINO RUN!

Scan the QR code below to download the full Arduino sketch for this project!

Full Dino Run Code QR
Igniting the Passion for Robotics in Kids

Leave A Comment

Your email address will not be published. Required fields are marked *