OLED Tetris Game Using Arduino Nano
by DESHBOT in Circuits > Arduino
14 Views, 0 Favorites, 0 Comments
OLED Tetris Game Using Arduino Nano
The objective of this project is to create a small playable Tetris game using an Arduino Nano, a 128×64 OLED display, and two push buttons.
Supplies
DESHBOT SHIELD
OLED DISPLAY
INBUILD BUTTON
Pin Connections
OLED Display
OLED PinArduino Nano
VCC - 5V
GND - GND
SDA - A4
SCL - A5
Buttons
ButtonArduino Nano
Left Button - D12
Right Button - D10
Other side of both buttons - GND
The buttons use the Arduino's internal INPUT_PULLUP, so external resistors are not required.
Working Principle
When the Arduino starts, the OLED displays the TETRIS title screen.
After the start screen, a random Tetris piece appears at the top of the game area.
The program continuously checks the two buttons:
- Press D12 → piece moves left.
- Press D10 → piece moves right.
- Press both buttons → piece rotates.
- The piece automatically moves downward.
- When the piece reaches another block or the bottom, it becomes fixed.
- The program checks for completed horizontal lines.
- Completed lines are removed and the player receives points.
- When the blocks reach the top and a new piece cannot be placed, GAME OVER is displayed.
Tetris Pieces
The program contains seven standard Tetris pieces:
- I
- O
- T
- L
- J
- S
- Z
The pieces are selected randomly using the Arduino's random() function.
Downloads
Conclusion
This project demonstrates how an Arduino Nano can be used to create a complete miniature game using an OLED display and two buttons. It combines graphics, button input, randomization, collision detection, rotation, scoring, and game-state management into a simple embedded-system project.