Projects / Stacker arcade game

Stacker arcade game

Intermediate2 hGuided buildReviewed

Build it step by step

0 of 6 done
  1. NANO

    Chain the matrices

    Feed the Nano into module 1 DIN, then module 1 DOUT to module 2 DIN. Share 5V, GND, CS and CLK.

  2. NANO12.3 mA

    Check one module first

    Light all LEDs with a test sketch, then both.

  3. NANO

    Mount them vertically

    Module 1 at the bottom, module 2 above, in a small frame.

  4. NANO

    Add the arcade button and buzzer

    Button to D2 and GND, buzzer to D8.

  5. NANO

    Upload and play

    A three-block row slides. Press to stop it. Blocks that overhang the row below are trimmed off.

  6. NANO

    Tune

    Change the starting delay and the speed-up per level in the last lines.

In short

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

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Matrix 1 (bottom) VCC and GNDNano 5V and GNDSupply
Matrix 1 DIN, CS, CLKNano D12, D10, D11SPI-style input
Matrix 1 DOUT, CS, CLKMatrix 2 DIN, CS, CLKDaisy chain upwards
Matrix 2 (top) VCC and GNDNano 5V and GNDSupply
Arcade buttonNano D2 and GNDStop the row
Passive buzzer +Nano D8Sounds
Passive buzzer -Nano GNDReturn

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.

CheckExpected
Press to stop a perfect rowRow stays full width
OverhangRow is trimmed and the next row is narrower
Miss completelyGame over sound and restart
Reach row 16Win 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 →

Ask Lark AI

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.