loading
This is my Arduino Simon Say version

You'll need :
6 X 220ohm Resistors
3 X leds, one for each color, green, red, yellow
3 X Push buttons
1 X Arduino
Few cables

Step 1: Circuits Diagram

5 Volts pass through the buttons to the leds and to pins 5,6,7 of the arduino digital pins to sense a button press.
This way I didn't need to handle lighting up the leds on a button press, they light up electrictly.

The Arduino's digital pins 8,9,10 are connected to the leds right after the buttons to light them up from the program.

Step 2: The Code :

// Buttons Pins
int GrBpin = 5; int ReBpin = 6; int YeBpin = 7; // Leds Pins int GrLpin = 8; int ReLpin = 9; int YeLpin = 10; // Leds Array int LedA [10]; //Computer randomed led stack int userLed [10]; // User press stack int Level; // Corrent Level counter boolean nextL = true; // Correct / Mistake boolean void setup() { randomSeed(analogRead(0)); Serial.begin (9600); // initialize the digital pin as an output. pinMode(GrLpin, OUTPUT); pinMode(ReLpin, OUTPUT); pinMode(YeLpin, OUTPUT); pinMode(GrBpin, INPUT); pinMode(ReBpin, INPUT); pinMode(YeBpin, INPUT); } void loop() { restartLeds (); while (nextL == true && Level <=10) { // Level and mistake loop compLeds (); // Plays Leds to the corrent level int ubc=0; while (ubc<=Level-1) { // Reads user input buttons and compare to the comp. loop (one input by one userLed [ubc] = w8press (); if (userLed [ubc] != LedA [ubc]) { nextL = false; ubc = Level-1; } ubc ++; } Level ++; delay (1000); // Wait 2 second between levels } if (nextL == false) { Loose (); delay (3000); } if (nextL == true && Level >=10) winnerDance() ; } // Void Loos - leds play for loosing void Loose () { digitalWrite (GrLpin, HIGH); digitalWrite (ReLpin, HIGH); digitalWrite(YeLpin, HIGH); delay (200); digitalWrite (GrLpin, LOW); digitalWrite (ReLpin, LOW); digitalWrite(YeLpin, LOW); delay (200); digitalWrite (GrLpin, HIGH); digitalWrite (ReLpin, HIGH); digitalWrite(YeLpin, HIGH); delay (200); digitalWrite (GrLpin, LOW); digitalWrite (ReLpin, LOW); digitalWrite(YeLpin, LOW); } // Void winnerDance - the dance of the winner void winnerDance () { for (int id=1; id <= 5; id++) { Serial.println (id); digitalWrite (GrLpin, HIGH); digitalWrite (ReLpin, LOW); digitalWrite(YeLpin, LOW); delay (100); digitalWrite (GrLpin, LOW); digitalWrite (ReLpin, HIGH); delay (100); digitalWrite (ReLpin, LOW); digitalWrite(YeLpin, HIGH); delay (100); } delay (2900); } // Function w8press is wating for the button to be pressed and return the pressed button pin number boolean w8press () { boolean bottPress = false; while (bottPress == false) { if (digitalRead(GrBpin) == HIGH) { // Read Green's led button while (digitalRead (GrBpin) == HIGH) {} // Wait for button to be relesed return GrLpin; //Return green's led pin bottPress = true; } if (digitalRead(ReBpin) == HIGH) { //Same like the green's only for the red while (digitalRead (ReBpin) == HIGH) {} return ReLpin; bottPress = true; } if (digitalRead(YeBpin) == HIGH) { //Same like the green's only for the yellow while (digitalRead (YeBpin) == HIGH) {} return YeLpin; bottPress = true; } } delay (200); } // Void comLeds runs the led one by one to the corrent level void compLeds () { int ind = 0; while (ind < Level) { // Serial.println (LedA [ind]); digitalWrite (LedA [ind], HIGH); delay (500); digitalWrite (LedA [ind], LOW); if (LedA [ind] == LedA [ind+1]) delay (200); if (ind >= 9) break ; ind ++; } } // Void restartLeds insert randomes led's pin nmuber into the computer leds stack void restartLeds () { Level = 1; nextL = true; int ind = 0; while (ind < 10) { LedA [ind] = random (GrLpin, YeLpin+1); ind ++; } }

Step 3: Play...

Have fun

About This Instructable

1,408views

12favorites

License:

More by udubinsky:ENC28J60 Using Ethernet With Arduino Electro Double Pie Face Showdown  Never Forget It on - Energy Saver 
Add instructable to: