Arduino Dinausore Game

Arduino UNO 20-02-25
27 0

Tutorial plan

1- Presentation of the Dinausore game

2- Objective of our game

3- Required Components

4- Component Wiring

5- Arduino program

 

 

Presentation of the Dinausore game

The Dinosaur Game (also known as the Chrome Dino Game) is a simple endless runner game built into Google Chrome. It appears when there is no internet connection and features a pixelated T-Rex dinosaur that runs through a desert landscape, avoiding obstacles like cacti and flying pterodactyls.

Game Concept

The player controls a T-Rex that automatically runs from left to right.

The main objective is to jump over obstacles by pressing the spacebar (or tapping on mobile).

The game gradually increases in speed, making it more challenging over time.

The game ends if the dinosaur collides with an obstacle.

Objective of our game

This project replicates the Google Chrome Dinosaur Game using an Arduino UNO, a push button for controls, and a 16x2 LCD I2C screen for the display.

Overview of the Game Functioning

- The LCD screen displays a simplified version of the Dino Game using text-based graphics.

- The dinosaur (Dino) automatically moves forward on the screen.

- Obstacles (cacti) appear randomly and move from right to left.

- The player must press a push button to make the dinosaur jump over obstacles.

- If the dinosaur collides with an obstacle, the game ends, and the score is displayed.

Game Logic and Step-by-Step Execution

Initialization

The LCD screen is initialized using the I2C interface.

The custom character set is loaded to represent the dinosaur and obstacles in a simple pixel form.

The button pin is set as an input with a pull-down resistor to detect button presses.

The game loop continuously performs the following actions:

Move the obstacles:

Cacti are randomly generated and move from right to left.

If an obstacle reaches the leftmost side of the screen, it disappears.

Check for Jump Input:

If the push button is pressed, the dinosaur jumps.

A simple animation effect moves the dinosaur up and then back down.

Collision Detection:

If the dinosaur is on the ground when an obstacle reaches it, a collision is detected.

The game ends and displays a "Game Over" message.

Score Calculation:

Each successfully avoided obstacle increases the score.

The score is displayed in the top-right corner of the LCD screen.

 

Required Components

Arduino UNO

Arduino Uno

It controls the game logic, reads input from the button, updates the LCD display, and manages the score.

LCD I2C Display

Pinouts of 1602 LCD display with I2C

It displays the dinosaur, obstacles, and game score using custom characters.

Push Button

bouton-poussoir

It Allows the player to make the dinosaur jump.

Buzzer

It generates sounds for jumping and collisions.

Jumper Wires

Jumper wires

Jumper wires will be used to make connections between the components.

Breadboard:

Breadboard

A breadboard can be used to create a temporary circuit for testing and prototyping.

 

Component Wiring

LCD I2C screen→ Arduino UNO

- SDA → A4 analogic pin

- SCL → A5 analogic pin

- VCC → 5V

- GND → GND

Push Button→ Arduino UNO

- Connect one leg of the push button to pin 5 of the Arduino.

- Connect another leg of the push button to the 5V pin of the Arduino.

- Place a 10k Ohm resistor between the third leg of the push button and the GND pin of the Arduino.

Buzzer → Arduino UNO

- Connect the positive pin to a digital output pin (e.g., D3) on Arduino.

- Connect the negative pin to GND.

 

Arduino program

Here’s an example Arduino code to implement this game:

You must install this library  "LiquidCrystal_I2C".

How the Code Works

Initialization: Sets up LCD, button, and buzzer.

Game Loop: Moves obstacles, detects jumps, checks collisions, and updates score.

Collision Handling: Ends game if the dinosaur hits an obstacle.

Dynamic Speed: The game becomes harder over time.

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

+216 92 886 231

medaliprof@gmail.com

Pictures of the articles

Robotic site created by MedAli-Teacher info