Arduino game

Quick info

Engine: Arduino
Programming language: C++,
Platform: Arduino
Role: Developer,
Team size: 1,
Date: Januari 2019

About

This project introduced me for the first time with Arduino’s.
I made a small game were there’s a cube going from the left to the right and you need to press the button on a specific marked area to gain a point, and if you miss you lose a point.

This project made me interested in working with hardware and electronics. I even started a personal project because of this. That project is about to read data from a game and show it in real time on hardware(hopefully soon visible on my portfolio)

The buttons / key binds

The player can set the speed of the moving cube by rotating the blue nop.
The red button is to mute the sound.
The most top button is to update the UI but that isn’t needed anymore.
The other one is to click on the marked area to gain a point

Code snippet:

This function handles the player movement.

//------------------------------------------------------------------------------------------------------------------------
//                                                        OnInput()
//------------------------------------------------------------------------------------------------------------------------
void OnInput(){
  //check if the current player pos is NOT the objective remove score
	if(selected != objPos){
		if(score<=0){
			score = 0;
		}
		else {
			score--;
			tone(7, 150, 500);
		}
	}
	else {
      	//if the player pos is the obj add score 
		score++;
		tone(7, 1000, 500);
		CleanScreen();
		CreateNewObjective();
    }
  	//update lcd
	lcd.setCursor(0,3);
    lcd.write("score ");
    lcd.write((String(score)).c_str());
}