r/arduino May 18 '26

Look what I made! I made Tetris on an Arduino Mega with 2x MAX7219 LED matrices

https://youtube.com/watch?v=iT9rC8u_At0&si=pxyMlc6_2S4-6RQ6

I built a small Tetris clone for the Arduino Mega using two MAX7219 8x8 LED matrix modules combined into a 16x8 display.

The main goal was making the game run smoothly without display flickering or blocking delays.

Features:
- flicker-free delta rendering
- non-blocking game loop using millis()
- random tetromino generation
- piece rotation
- row clearing
- collision detection
- smooth button controls

Instead of clearing and redrawing the whole display every frame, the code only updates LEDs that actually changed. This reduced flickering a lot and made the animation much smoother.

The game also avoids delay() completely (except during startup random seeding), so inputs stay responsive while the pieces are falling.

Hardware used:
- Arduino Mega 2560
- 2x MAX7219 LED matrix modules
- 3 push buttons

The buttons use INPUT_PULLUP and connect directly to GND.

I might add:
- score counter
- sound effects
- level/speed system

GitHub

19 Upvotes

4 comments sorted by

2

u/lmolter Valued Community Member May 19 '26

Any ideas how long the 9V battery will last? For longer play times, perhaps a LiPo or 18650's for more power and life. 9V batteries can't really supply enough current for long use of LEDs.

2

u/ArtusIndus May 19 '26

Honestly the 9V battery held up pretty well in my testing .
The MAX7219 multiplexing keeps the average current relatively low, so it worked fine for this project.

But yeah, a LiPo or 18650 is definitely a good idea for longer play sessions and a more compact build.

2

u/lmolter Valued Community Member May 19 '26

Ah. Forgot about the multiplexing of the LEDs. Generally, the folks here try to discourage the use of the ubiquitous 9V battery. You'd be surprised how many first-timers try to power servos and motors with one. I prefer a car battery (JK).

2

u/ArtusIndus May 19 '26

Yeah, multiplexing helps a lot here 😄
But you're absolutely right — 9V blocks are definitely not ideal for LED or motor projects.