Introduction: Arduino Led Mini Game

In this arduino project I am going to make a simple mini game with leds. In this game the leds turn on and off the one after the other very quickly. When you push the button you see in the images the led that is on remains on and all the other stop blinking. The aim of this mini game is to push the button and make the middle led (the red led) stay on. If you don't succeed in doing it you just let the button and try again.

Step 1: Materials

You will need :

Arduino uno

1 breadboard

cables

1 pushbutton

1 piezo buzzer

1 resistor

2 blue leds

2 green leds

2 yellow leds

1 red led

Step 2: Making the Circuit

Connect a blue led from pin 13 to ground. Connect a green led from pin 12 to ground. Connect a yellow led from pin 11 to ground. Connect the red led from pin 10 to ground. Connect a yellow led from pin 9 to ground. Connect a green led from pin 8 to ground. Connect a blue led from pin 6 to ground. Connect the button to pin 4 , 5v and to the resistor to ground. Connect the piezo buzzer from pin 2 to ground.

Step 3: Code

copy the code

int tap1 = 0;
int tap = 0; void setup(){ Serial.begin(9600); pinMode(13,OUTPUT); pinMode(12,OUTPUT); pinMode(11,OUTPUT); pinMode(10,OUTPUT); pinMode(9,OUTPUT); pinMode(8,OUTPUT); pinMode(6,OUTPUT); pinMode(4,INPUT); } void loop(){ blue1(); button(); green1(); button(); yellow1(); button(); red(); button(); yellow(); button(); green(); button(); blue(); button(); green3(); button(); yellow3(); button(); red2(); button(); yellow2(); button(); green2(); button(); } void blue1(){ if(tap == 0){ digitalWrite(13,HIGH); delay(100); digitalWrite(13,LOW); tap1 = tap1 + 1; }} void button(){ tap = digitalRead(4); Serial.print(tap); if(tap == 1){ if(tap1 == 1){ digitalWrite(12,HIGH); tone(2,100,20); delay(1); digitalWrite(12,LOW); } if(tap1 == 2){ digitalWrite(11,HIGH); tone(2,100,20); delay(1); digitalWrite(11,LOW); } if(tap1 == 3){ digitalWrite(10,HIGH); tone(2,500,20); delay(1); digitalWrite(10,LOW); } if(tap1 == 4){ digitalWrite(9,HIGH); tone(2,100,20); delay(1); digitalWrite(9,LOW); } if(tap1 == 5){ digitalWrite(8,HIGH); tone(2,100,20); delay(1); digitalWrite(8,LOW); } if(tap1 == 6){ digitalWrite(6,HIGH); tone(2,100,20); delay(1); digitalWrite(6,LOW); } if(tap1 == 0){ digitalWrite(13,HIGH); tone(2,100,20); delay(1); digitalWrite(13,LOW); }}} void green1(){ if(tap == 0){ digitalWrite(12,HIGH); delay(100); digitalWrite(12,LOW); tap1 = tap1 + 1; }} void yellow1(){ if(tap == 0){ digitalWrite(11,HIGH); delay(100); digitalWrite(11,LOW ); tap1 = tap1 + 1; }} void red(){ if(tap == 0){ digitalWrite(10, HIGH); delay(100); digitalWrite(10,LOW); tap1 = tap1 + 1; }} void yellow(){ if(tap == 0){ digitalWrite(9,HIGH); delay(100); digitalWrite(9,LOW); tap1 = tap1 + 1; }} void green(){ if(tap == 0){ digitalWrite(8,HIGH); delay(100); digitalWrite(8,LOW); tap1 = tap1 + 1; }} void blue(){ if(tap == 0){ digitalWrite(6,HIGH); delay(100); digitalWrite(6,LOW); tap1 = tap1 - 1; }} void green3(){if(tap == 0){ digitalWrite(8,HIGH); delay(100); digitalWrite(8,LOW); tap1 = tap1 - 1; }} void yellow3(){ if(tap == 0){ digitalWrite(9,HIGH); delay(100); digitalWrite(9,LOW); tap1 = tap1 - 1; }} void red2(){ if(tap == 0){ digitalWrite(10,HIGH); delay(100); digitalWrite(10,LOW); tap1 = tap1 - 1; }} void yellow2(){ if(tap == 0){ digitalWrite(11,HIGH); delay(100); digitalWrite(11,LOW); tap1 = tap1 - 1; }} void green2(){ if(tap == 0){ digitalWrite(12,HIGH); delay(100); digitalWrite(12,LOW); tap1 = 0; }}
Epilog Contest 8

Participated in the
Epilog Contest 8

Circuits Contest 2016

Participated in the
Circuits Contest 2016