Build it step by step
0 of 6 doneChain the matrices
Feed the Nano into module 1 DIN, then module 1 DOUT to module 2 DIN. Share 5V, GND, CS and CLK.
Check one module first
Light all LEDs with a test sketch, then both.
Mount them vertically
Module 1 at the bottom, module 2 above, in a small frame.
Add the arcade button and buzzer
Button to D2 and GND, buzzer to D8.
Upload and play
A three-block row slides. Press to stop it. Blocks that overhang the row below are trimmed off.
Tune
Change the starting delay and the speed-up per level in the last lines.
How do you build a stacker arcade game?
Stop a sliding row of LEDs to stack blocks to the top of a tall matrix, like the arcade game. You need Arduino Nano, MAX7219 8x8 LED matrix module × 2, Arcade push button 30 mm, Passive buzzer and Jumper wires male to male (40 pcs, 20 cm). It takes 6 steps and about 120 minutes.
- Level
- Intermediate
- Time
- About 120 min
- Parts
- 5
Parts list
- Development BoardsBuyArduino Nano × 1
- DisplaysBuy
- Switches
- Motors & ActuatorsBuyPassive buzzer × 1
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Matrix 1 (bottom) VCC and GND | Nano 5V and GND | Supply |
| Matrix 1 DIN, CS, CLK | Nano D12, D10, D11 | SPI-style input |
| Matrix 1 DOUT, CS, CLK | Matrix 2 DIN, CS, CLK | Daisy chain upwards |
| Matrix 2 (top) VCC and GND | Nano 5V and GND | Supply |
| Arcade button | Nano D2 and GND | Stop the row |
| Passive buzzer + | Nano D8 | Sounds |
| Passive buzzer - | Nano GND | Return |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "LedControl" by Eberhard Fahle. Stack the two modules vertically with module 1 at the bottom. If rows appear mirrored or turned, flip the modules or change the mapping in render(). Overlap is found with a bit mask, and the width after trimming is the count of set bits.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <LedControl.h>
LedControl lc(12, 11, 10, 2); // DIN, CLK, CS, two modules
const byte BTN = 2, BUZZ = 8;
byte rows[16]; // settled rows, bottom is 0
int y, x, width, dir;
byte prevMask;
unsigned long lastMove;
int delayMs;
byte maskFor(int pos, int w) { return ((1 << w) - 1) << pos; }
void render(byte cur) {
for (byte r = 0; r < 16; r++) {
byte m = rows[r];
if (r == y) m |= cur;
lc.setRow(r / 8, r % 8, m); // turn the modules if your display looks upside down
}
}
void newGame() {
for (byte r = 0; r < 16; r++) rows[r] = 0;
y = 0; x = 0; width = 3; dir = 1; prevMask = 0xFF; delayMs = 220; lastMove = millis();
}
void flash(bool win) {
for (byte i = 0; i < 6; i++) {
for (byte d = 0; d < 2; d++) lc.setIntensity(d, i % 2 ? 2 : 15);
tone(BUZZ, win ? 1200 + i * 200 : 400 - i * 40, 150);
delay(200);
}
for (byte d = 0; d < 2; d++) lc.setIntensity(d, 6);
}
void setup() {
pinMode(BTN, INPUT_PULLUP);
for (byte d = 0; d < 2; d++) { lc.shutdown(d, false); lc.setIntensity(d, 6); lc.clearDisplay(d); }
newGame();
}
void loop() {
byte cur = maskFor(x, width);
render(cur);
if (millis() - lastMove > delayMs) {
lastMove = millis();
x += dir;
if (x + width >= 8) { x = 8 - width; dir = -1; }
if (x <= 0) { x = 0; dir = 1; }
}
if (digitalRead(BTN) == LOW) {
while (digitalRead(BTN) == LOW) {}
byte overlap = cur & prevMask;
if (overlap == 0) { flash(false); newGame(); return; }
width = 0; for (byte b = overlap; b; b >>= 1) width += b & 1; // blocks left after trimming
rows[y] = overlap; prevMask = overlap;
tone(BUZZ, 800 + y * 60, 80);
y++;
if (y == 16) { flash(true); newGame(); return; }
x = random(0, 8 - width + 1); dir = random(2) ? 1 : -1;
delayMs = max(40, 220 - y * 11); // speed up each level
}
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Press to stop a perfect row | Row stays full width |
| Overhang | Row is trimmed and the next row is narrower |
| Miss completely | Game over sound and restart |
| Reach row 16 | Win flash and restart |
If it does not work
Display upside down or mirrored
Rotate the modules or change the row mapping in render().
Only one matrix works
DOUT to DIN link is missing or the second module is not powered.
Dim or flickering
Use a good 5 V supply and short wires.
Button feels slow
Debounce with a short delay and keep the loop free of long delays.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the stacker arcade game?
Arduino Nano, MAX7219 8x8 LED matrix module × 2, Arcade push button 30 mm, Passive buzzer and Jumper wires male to male (40 pcs, 20 cm).
How long does the stacker arcade game take to build?
About 120 minutes for a intermediate maker, in 6 steps.
How do I know the stacker arcade game works?
Press to stop a perfect row: Row stays full width. Overhang: Row is trimmed and the next row is narrower. Miss completely: Game over sound and restart.
Display upside down or mirrored: what should I check?
Rotate the modules or change the row mapping in render().
Only one matrix works: what should I check?
DOUT to DIN link is missing or the second module is not powered.
Dim or flickering: what should I check?
Use a good 5 V supply and short wires.
Button feels slow: what should I check?
Debounce with a short delay and keep the loop free of long delays.
