Arduino TETRIS Game

Arduino UNO 08-03-25
29 0

Tutorial plan

1- Presentation of Tetris game

2- Description of Arduino Tetris game

3- Required Components

4- Component Wiring

5- Tetris game program

 

 

Presentation of Tetris game

Tetris is a tile-matching puzzle game where players manipulate falling geometric shapes, known as Tetrominoes, to create complete horizontal lines. The game was originally designed by Alexey Pajitnov in 1984 and has since become one of the most iconic video games of all time.

1. The Playing Field

The game takes place on a rectangular grid of 10 columns and 20 rows (standard size).

Tetrominoes fall from the top of the grid and move downward.

The player must arrange and rotate the pieces to fit them together.

The goal is to create full horizontal lines without gaps.

2. Tetrominoes (Game Pieces)

There are seven different Tetrominoes, each consisting of four squares arranged in unique shapes (L, T, I, O, S, Z, and J).

Rotation: Pieces can rotate 90° clockwise or counterclockwise to fit different spaces.

Movement: The player can move pieces left, right, or make them fall faster.

3. Line Clearing

A line is cleared when all columns in a row are filled.

Cleared lines disappear, and the blocks above shift downward.

Players earn more points for clearing multiple lines at once:

1 line: 100 points

2 lines: 300 points

3 lines: 500 points

4 lines (Tetris!): 800 points

4. Increasing Difficulty

As the player clears more lines, the game speed increases, making it harder to place pieces correctly.

At higher levels, Tetrominoes fall faster, reducing reaction time.

5. Game Over

The game ends when the stack of Tetrominoes reaches the top of the playing field.

 

Description of Arduino Tetris game

This project implements a Tetris game using an Arduino UNO, an LCD I2C screen, a joystick for control, and a buzzer for sound effects.

1. Initial Setup

The Arduino initializes the LCD I2C screen and buzzer.

The joystick module is set up as an input.

A random Tetromino appears at the top of the grid.

2. Tetromino Movement

The player moves the Tetromino left/right with the joystick.

Pressing the joystick rotates the Tetromino if possible.

The Tetromino automatically moves downward at regular intervals.

If the player tilts downward, the Tetromino falls faster (soft drop).

3. Collision Detection

The Arduino checks if the Tetromino hits the floor or collides with other blocks.

If a collision is detected:

a) The piece stops moving.

b) The next Tetromino appears.

c) If a full line is completed, it is cleared.

4. Line Clearing

If a row is fully filled, it disappears, and all blocks above it move down.

The LCD refreshes to reflect the new grid state.

The buzzer plays a short sound when a line is cleared.

5. Increasing Difficulty

The game gradually speeds up after a certain number of lines are cleared.

6. Game Over Condition

If a new Tetromino cannot be placed because the grid is full, the game ends.

The LCD displays "Game Over", and the buzzer plays a long tone.

 

Required Components

 Arduino UNO

Arduino Uno

Acts as the brain of the Tetris game, processing inputs and updating the display.

Reads signals from the joystick for movement and rotation of Tetrominoes.

Controls the LCD I2C screen to display the game.

Sends sound signals to the buzzer for game events.

LCD 16x2 I2C Screen

Pinouts of 1602 LCD display with I2C

Displays the game grid (simplified version due to small size).

Shows the current score and level.

Provides visual feedback when lines are cleared or the game is over.

Joystick Module

Controls left/right movement of Tetrominoes.

Rotates the piece when the joystick button is pressed.

Moves the piece downward faster when pushed forward.

Buzzer

Generates sound effects for game actions

Breadboard

plaque d'essai

Provides an easy way to connect components without soldering.

Allows multiple components (joystick, buzzer, LCD) to share the same power and ground connections.

Jumpers

Fils de connexion

Connects all components to the Arduino UNO and breadboard.

 

Component Wiring

 

Joystick Module:

Connect VCC to 5V on Arduino.

Connect GND to GND on Arduino.

Connect X-axis to A0 and Y-axis to A1 on Arduino.

Connect the joystick button to a digital pin (e.g., D2).

LCD Screen:

Connect SDA to A4, SCL to A5, VCC to 5V, and GND to GND.

Buzzer:

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

Connect the negative pin to GND.

 

Arduino program

Here is the Arduino code for a simplified Tetris game using an Arduino UNO, a 16x2 LCD I2C screen, a joystick, and a buzzer. Since the LCD 16x2 is small, we create a minimalist Tetris using custom characters to represent Tetrominoes.

import this library : LiquidCrystal_I2C  for I2C LCD screen.

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