Lesson plan

Build Tetris on an LED matrix lesson plan

Build a complete falling-blocks game on two 8x8 LED matrices: a field of sixteen bytes, seven pieces, quarter turns, line clears and levels.

3 chapters, 6 lessons, about 5 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

The unit

Objectives and materials

By the end, students can

  • Sixteen bytes on two matrices, and seven shapes that fall.
  • Turn the pieces, clear the lines and speed it up.
  • Put it all together into a game worth sharing.

Materials for the whole unit

  • Arduino Uno R3
  • Buzzer
  • LED matrix, 8x8 x 2
  • Thumb stick

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 1 h 35 min

The field and the pieces

Sixteen bytes on two matrices, and seven shapes that fall.

LessonTimeWhat students do
The board gridTwo 8x8 LED matrices make one field 8 wide and 16 tall. Keep it as sixteen bytes, drive it over three wires, and draw on it with the joystick.45 min
  1. Sixteen bytes
  2. Two chips, one screen
  3. Flip one bit
  4. A full row is 255
  5. Bits are pictures
PiecesThe seven shapes four squares can make, each a list of cells in a box. Make them fall, steer them, and stop them on the floor and on each other.50 min
  1. Seven shapes of four
  2. Falling is a test
  3. Steer it
  4. The wall
  5. Faster, and onto the stack
  6. Meet all seven

Materials

  • Arduino Uno R3
  • Buzzer
  • LED matrix, 8x8 x 2
  • Thumb stick

Check for understanding

Each student finishes "Pieces" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Meet all seven".

Chapter 2. About 2 h 25 min

The rules of the game

Turn the pieces, clear the lines and speed it up.

LessonTimeWhat students do
RotationA quarter turn is a swap and a flip: (x, y) becomes (n - 1 - y, x). Turn every piece, find the one that never changes, and kick off the walls.50 min
  1. A piece that holds still
  2. A swap and a flip
  3. Full circle
  4. Kick off the wall
  5. The one that never changes
  6. Why the Stick gets a big box
Line clearsFind full rows with one comparison, pull everything above them down, and score more for more rows at once. Two puzzles, then free play.45 min
  1. A puzzle on the board
  2. Two at once
  3. The next puzzle
  4. Four at once
  5. Score the hard ones
Speed levelsA level every 4 lines, each 15 percent faster, timed with millis() so the stick never feels sticky. Then the moment every game needs: game over.50 min
  1. Level 1
  2. A shortcut for testing
  3. Hear it
  4. Never call delay()
  5. Soft drop
  6. Game over

Materials

  • Arduino Uno R3
  • Buzzer
  • LED matrix, 8x8 x 2
  • Thumb stick

Check for understanding

Each student finishes "Speed levels" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Game over".

Chapter 3. About 1 h

A pocket game

Put it all together into a game worth sharing.

LessonTimeWhat students do
Project: a pocket falling-blocks gameThe whole game: a title screen, pieces from a shuffled bag, a lock click, pause, a best score, and it is yours to change and share.60 min
  1. The title screen
  2. Start, and seed the dice
  3. The bag
  4. The click
  5. Pause
  6. Your best score
  7. Make it yours

Materials

  • Arduino Uno R3
  • Buzzer
  • LED matrix, 8x8 x 2
  • Thumb stick

Check for understanding

Each student finishes "Project: a pocket falling-blocks game" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Make it yours".

Your class

Teach this unit as a class

Start a class from this course and its 6 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.