Now it plays the Tetris theme song while you’re playing! An ATtiny85 is used to store the notes matrix and it listens to the ATmega328p on two pins to either play/stop the music or just pause it. I used the Arduino-Tiny core instead of the one from MIT HLT for the ATtiny85 since it supports the Tone() function in the Arduino library. It was actually quite hard to fit all the frequency values and duration values in a mere 512 bytes of RAM on the tiny85.
Here is a few more components that I’m considering to add to this Tetris game in the future:
-A 3-axis accelerometer (MMA8452Q) to provide another form of input;
-A LED bar graph, or just a couple LEDs, that could reflect the game progress/score.
-A separate small 8*8 or two 5*7 single colour LED matrices to display the next Tetris piece, and to allow the player to store the current piece.
Since I’ve written a Tetris in Python half a year ago, It wasn’t that difficult for me to write this one for the Arduino. Other than the four arrow keys that are also used for the Snake game, another tact switch was added to immediately drop a piece to the bottom.
Changes made in this version:
Changed to another brand of breadboard, so it’s much more compact.
Added black and white key caps to make it more intuitive to play.
Replaced the 3W speaker with a 1W one to make the piano more compact yet still keeping the sound relatively loud.
I was testing the matrix and all the connections using this “scrolling rainbow” sketch before I started writing the snake game.
The LED matrix is controlled using eight 595 shift registers.
The game over screen.