loading
This is my led game that I'll show you how to make.

Step 1: What You Need

You need
Arduino uno
Mini USB to standard USB
Mac or windows
Breadboard
LEDs
Tact switch
4x 33ohm + 1x 10kohm resistors
Jumper cables

Step 2: How to Circuit the Board

Just look at the picture

Step 3: Typing the Code With Arduino

Look closely at the pictures
<p>/*</p><p> Tutorial 4 &ndash; Digital Input and Output Game</p><p> In this game, the LED will loop from white, yellow, green, red</p><p> then back to white. The goal is to press the push button at the exact</p><p> moment when the green LED is ON. Each time you got it right, the LED</p><p> will speed up and the difficulty will increase.</p><p>*/</p><p>int currentLED = 2;</p><p>int delayValue = 200;</p><p>void setup()</p><p>{</p><p>// initialize digital pin 12 as input;</p><p>pinMode(12, INPUT); // button input</p><p>// initialize digital pin 2 to 5 as output:</p><p>pinMode(2, OUTPUT); // white LED</p><p>pinMode(3, OUTPUT); // yellow LED</p><p>pinMode(4, OUTPUT); // green LED</p><p>pinMode(5, OUTPUT); // red LED</p><p>}</p><p>int checkInput()</p><p>{</p><p>if (digitalRead(12) == 0)</p><p>{</p><p>return 1;</p><p>}</p><p>else</p><p>{</p><p>return 0;</p><p>}</p><p>}</p><p>void loop()</p><p>{</p><p>// Check if the button is press at the right moment</p><p>if (digitalRead(12) == 0)</p><p>{</p><p>if (currentLED == 4)</p><p>{</p><p>// Blink the correct (green) LED</p><p>digitalWrite(4, HIGH);</p><p>delay(200);</p><p>digitalWrite(4, LOW);</p><p>delay(200);</p><p>digitalWrite(4, HIGH);</p><p>delay(200);</p><p>digitalWrite(4, LOW);</p><p>delay(200);</p><p>// Speed up the LEDs</p><p>delayValue = delayValue - 20;</p><p>}</p><p>else</p><p>{</p><p>// Blink the wrong LED</p><p>digitalWrite(currentLED, HIGH);</p><p>delay(200);</p><p>digitalWrite(currentLED, LOW);</p><p>delay(200);</p><p>digitalWrite(currentLED, HIGH);</p><p>delay(200);</p><p>digitalWrite(currentLED, LOW);</p><p>delay(200);</p><p>}</p><p>}</p><p>// Loop LED from white &ndash;&gt; yellow &ndash;&gt; green &ndash;&gt; red</p><p>digitalWrite(currentLED, HIGH);</p><p>delay(delayValue);</p><p>digitalWrite(currentLED, LOW);</p><p>delay(delayValue);</p><p>currentLED = currentLED + 1;</p><p>if (currentLED &gt; 5)</p><p>{</p><p>currentLED = 2;</p><p>}</p><p>}</p>
<p>Perhaps you could put the code in a file to download. It's not very clear to copy from the pictures. Little more information about the game....how to play etc. I wanted to try and make it. </p>

About This Instructable

1,753views

18favorites

License:

Bio: Love 3d printing Arduino fanatic Raspberry pi lover Love GOD and JESUS CHRIST
More by potato_glados:Portable LED Game Led Game Arduino 
Add instructable to: