This is one of the most famous game concepts in the world. The goal is to dodge the meteorites falling from the sky, but there is a problem: they keep coming faster and faster. The only solution is to move faster too.
Do you think you can do it? Then I encourage you to build this project, for which you will need an 8x8 LED matrix and two buttons to move left and right.
If you want to learn how to build this project in a simple and quick way, stay on this page.
Table of contents
Explanation and gameplay of the mini game
The way this project works is simple: we need to dodge as many meteorites as possible. Sounds easy, right? The problem is that as time goes by, more meteorites fall and they move faster, so the game becomes harder and harder.
To move, we use two buttons: one moves to the left and the other to the right, making it possible to dodge the falling meteorites.
This is a very interesting Arduino project because, even though the code is fairly complex, the hardware assembly is quite simple. By building it, you will also learn how 8x8 LED matrices work.
Materials used in the project
The materials used in this project are very simple and should be easy to find. To make things easier, here is a list of all the components.
Below you can find a list of purchase links from different websites.
If you have any questions about the materials used in this project, feel free to leave a comment and we will reply as soon as possible.






WE DEVELOP YOUR IDEA
Need help with a project?
- Prototyping and MVPs
- Arduino and ESP32
- PCB design
- 3D part design
- Bluetooth connectivity
- Feasibility study
- Cost optimization
- Technical consulting
- Internet of Things
- Patent support
Step-by-step project video
If you want a more detailed walkthrough of how to build this project from start to finish, including a code explanation, the video below covers everything in a more visual and easier-to-follow way. And if you enjoy this kind of content, do not forget to subscribe.
Arduino wiring diagram for this project
To make the assembly easier, here is the wiring diagram. All the connections shown here match the code placed just below, so make sure your wiring is exactly as shown in the image.

Arduino code for the mini game
Below you can find the Arduino code developed specifically for this project. The pins used in the code are the same ones shown in the wiring diagram above.
If you want a more detailed explanation of the different parts of the code and how the project works, we recommend watching the video above.
Using this code is very simple. You just need to copy it and paste it into your Arduino compiler, for example the Arduino IDE. If you do not have it installed yet, here is our guide on how to install it for free.
If you have any questions, leave a comment on this page and we will reply as soon as possible.
//Canal de YouTube -> RobotUNO
//Proyecto esquivar meteoritos en matriz led
#include "LedControl.h"
LedControl lc=LedControl(12,11,10,1);
unsigned long delaytime=1000;
String scoreString;
int score;
int hundreds;
String scoreStr;
String scoreArr[] = {"" ,"" ,"" };
int pinLeft = 2;
int pinRight = 3;
volatile unsigned long buttonPressed;
int buttonDelay = 150;
volatile bool gameOver = false;
int tick;
int tickCounter = 1;
unsigned long now;
int ship;
int columns[] = {0,0,0,0,0,0,0,0};
int randomInt;
void setup() {
gameOver = false;
hundreds = 0;
scoreArr[0] = "";
scoreArr[1] = "";
scoreArr[2] = "";
score = 0;
tick = 300;
tickCounter = 1;
ship = 3;
now = millis();
buttonPressed = millis();
randomSeed(analogRead(15));
for(int i = 0; i<8; i++)
columns[i] = 0;;
lc.shutdown(0,false);
lc.setIntensity(0,1);
lc.clearDisplay(0);
pinMode(pinLeft, INPUT_PULLUP);
pinMode(pinRight, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(pinLeft), left, FALLING);
attachInterrupt(digitalPinToInterrupt(pinRight), right, FALLING);
}
void left()
{
if(millis() - buttonPressed > buttonDelay)
{
if(ship != 0)
ship--;
else
ship = 7;
lc.clearDisplay(0);
buttonPressed = millis();
}
if(gameOver == true){
gameOver = false;
setup();
}
}
void right()
{
if(millis() - buttonPressed > buttonDelay)
{
if(ship != 7)
ship++;
else
ship = 0;
lc.clearDisplay(0);
buttonPressed = millis();
}
if(gameOver == true){
gameOver = false;
setup();
}
}
void loop() {
if(millis() - now > tick){
score++;
now = millis();
if(tickCounter == 1){
tick = tick/1.02;
randomInt = random(0, 8);
if(columns[randomInt] == 0){
columns[randomInt] = 1;
}
}
if(tickCounter != 4)
tickCounter++;
else
tickCounter = 1;
for(int i = 0; i<8; i++){
if(columns[i] == 10)
columns[i] = 0;
if(columns[i] != 0)
columns[i]++;
}
lc.clearDisplay(0);
}
lc.setLed(0, 7, ship, true);
for(int i = 0; i<8; i++){
if(columns[i] > 0){
lc.setLed(0, columns[i]-2, i, true);
lc.setLed(0, columns[i]-3, i, true);
}
}
if(columns[ship] == 10 or columns[ship] == 9){
lc.clearDisplay(0);
for(int i = 0; i<4; i++){
lc.setLed(0,7,ship+i,true);
lc.setLed(0,7,ship-i,true);
lc.setLed(0,7-i,ship+i,true);
lc.setLed(0,7-i,ship-i,true);
lc.setLed(0,7-1.5*i,ship,true);
unsigned long time = millis();
int randomSound=1000;
while(millis() - time <= 250) {
randomSound--;
tone(9, random(randomSound, 1000));
lc.clearDisplay(0);
noTone(9);
}
delay(500);
scoreStr = String(score);
scoreArr[0] = scoreStr.charAt(0);
scoreArr[1] = scoreStr.charAt(1);
scoreArr[2] = scoreStr.charAt(2);
if(score < 100){
for(int i = 0; i<2; i++){
if(scoreArr[i] == "0")
draw0(1+i*4);
if(scoreArr[i] == "1")
draw1(1+i*4);
if(scoreArr[i] == "2")
draw2(1+i*4);
if(scoreArr[i] == "3")
draw3(1+i*4);
if(scoreArr[i] == "4")
draw4(1+i*4);
if(scoreArr[i] == "5")
draw5(1+i*4);
if(scoreArr[i] == "6")
draw6(1+i*4);
if(scoreArr[i] == "7")
draw7(1+i*4);
if(scoreArr[i] == "8")
draw8(1+i*4);
if(scoreArr[i] == "9")
draw9(1+i*4);
}
}
else{
for(int i = 1; i<3; i++){
if(scoreArr[i] == "0")
draw0(1+(i-1)*4);
if(scoreArr[i] == "1")
draw1(1+(i-1)*4);
if(scoreArr[i] == "2")
draw2(1+(i-1)*4);
if(scoreArr[i] == "3")
draw3(1+(i-1)*4);
if(scoreArr[i] == "4")
draw4(1+(i-1)*4);
if(scoreArr[i] == "5")
draw5(1+(i-1)*4);
if(scoreArr[i] == "6")
draw6(1+(i-1)*4);
if(scoreArr[i] == "7")
draw7(1+(i-1)*4);
if(scoreArr[i] == "8")
draw8(1+(i-1)*4);
if(scoreArr[i] == "9")
draw9(1+(i-1)*4);
}
for(int i = 1; i<10; i++){
if(scoreArr[0] == String(i))
hundreds = i;
}
for(int i = 1; i <= hundreds; i++){
lc.setLed(0,0,i-1,true);
lc.setLed(0,1,i-1,true);
delay(200);
}
}
gameOver = true;
while(gameOver == true){
}
}
}
void draw1(int position){
lc.setColumn(0,0+position,B00001000);
lc.setColumn(0,1+position,B00011111);
}
void draw2(int position){
lc.setColumn(0,0+position,B00010111);
lc.setColumn(0,1+position,B00010101);
lc.setColumn(0,2+position,B00011101);
}
void draw3(int position){
lc.setColumn(0,0+position,B00010001);
lc.setColumn(0,1+position,B00010101);
lc.setColumn(0,2+position,B00011111);
}
void draw4(int position){
lc.setColumn(0,0+position,B00011100);
lc.setColumn(0,1+position,B00000100);
lc.setColumn(0,2+position,B00011111);
}
void draw5(int position){
lc.setColumn(0,0+position,B00011101);
lc.setColumn(0,1+position,B00010101);
lc.setColumn(0,2+position,B00010111);
}
void draw6(int position){
lc.setColumn(0,0+position,B00011111);
lc.setColumn(0,1+position,B00010101);
lc.setColumn(0,2+position,B00010111);
}
void draw7(int position){
lc.setColumn(0,0+position,B00010000);
lc.setColumn(0,1+position,B00010011);
lc.setColumn(0,2+position,B00011100);
}
void draw8(int position){
lc.setColumn(0,0+position,B00011111);
lc.setColumn(0,1+position,B00010101);
lc.setColumn(0,2+position,B00011111);
}
void draw9(int position){
lc.setColumn(0,0+position,B00011101);
lc.setColumn(0,1+position,B00010101);
lc.setColumn(0,2+position,B00011111);
}
void draw0(int position){
lc.setColumn(0,0+position,B00011111);
lc.setColumn(0,1+position,B00010001);
lc.setColumn(0,2+position,B00011111);
}




