Simon Says Game; Arduino

Introduction: Simon Says Game; Arduino

I'm pretty sure all of us played Simon says when we were little, and personally I love the game! I never thought that the Simon says game can also be played using hardware! So that is the purpose of this instructable, I am going to be creating a Simon says game on tinkercad, you can use the app too if you don't have physical components! However, if you do have the physical components then use those!

Step 1: Supplies

Before you get into the supplies, just a heads-up I have written a component called an LDC, you don't need this in your project however you can use it as it will make your game more interesting.

Supplies:

  • Four 220 ohm resistors
  • 4 push buttons
  • A buzzer/piezo
  • Arduino Uno
  • 4 RGB LED'S
  • Wires
  • An LDC

Step 2: Gather Everything!

You should have everything in front of you so you can build the project/game with ease.

Step 3: TimeTo Connect

This connection is without the LDC, furthermore, we need to connect all the wires so that current can flow in the circuit and that the game will work. When this game starts you will hear a buzz from the buzzer/piezo and then the color will show up which is the first thing you have to copy. If you do the right steps, then you will hear a winning sound, and if you don't do the right steps, you will hear a losing sound. You want to make sure everything is in the right port, so here are a few important ports:

  • the turquoise wire is connected from A0 and is going in the terminal 1b of the last push button
  • the blue wire is connected from A1 and is going in the terminal 1b of the third push button
  • the pink wire is connected from A2 and is going in the terminal 1b of the second push button
  • the purple wire is connected from A3 and is going in the terminal 1b of the first push button
  • All these are then connected to their individual RGB LED'S

Before and if you share this game makes sure you test it out too see if it's working.

Step 4: Coding Time!

You need a code in order for your game to work, in this code you can change a few things in order to make things quicker, slow them down, or add something new. For example where it says delay(1000); randomSeed(analogRead(0)); you can change that to 2000 or a number greater, this will create more time before they light blinks which then starts the game.

Step 5: YAY

We finished the game! Now you know what to do when you're bored!😊

Image citaton

Step 6: Video

Be the First to Share

    Recommendations

    • Lamps and Lighting Contest

      Lamps and Lighting Contest
    • Robots Contest

      Robots Contest
    • Tinkercad Student Design Contest

      Tinkercad Student Design Contest

    3 Comments

    0
    Shapanya
    Shapanya

    3 months ago on Step 4

    can we have a copy paste of the code

    0
    Komalpreet
    Komalpreet

    Reply 3 months ago

    Yes of course!! Hope this helps!!!


    const int RED = 10, BLUE = 11, YELLOW = 12, GREEN = 13;
    const int RED_IN = A3, BLUE_IN = A2, YELLOW_IN = A1, GREEN_IN = A0;
    const int SPEAKER = 3;
    int sequence[100];
    int correct = 0;
    int button_pressed[100];
    void setup(){
    pinMode(RED, OUTPUT);
    pinMode(BLUE, OUTPUT);
    pinMode(YELLOW, OUTPUT);
    pinMode(GREEN, OUTPUT);
    pinMode(SPEAKER, OUTPUT);
    digitalWrite(RED, LOW);
    digitalWrite(BLUE, LOW);
    digitalWrite(YELLOW, LOW);
    digitalWrite(GREEN, LOW);
    for(int siren_start = 0; siren_start < 5 ; siren_start++){
    tone(SPEAKER, 1047);
    delay(100);
    noTone(SPEAKER);
    delay(200);
    }
    delay(1000);
    randomSeed(analogRead(0));
    }
    void loop(){
    for(int current = 0; current < 100; current++){
    sequence[current] = random(4);
    PLAY(current);
    LISTEN(current);
    if(correct == 1) {
    analogWrite(RED_IN,1023);
    analogWrite(BLUE_IN,1023);
    analogWrite(YELLOW_IN,1023);
    analogWrite(GREEN_IN,1023);
    tone(SPEAKER,523);
    delay(250);
    tone(SPEAKER,1047);
    delay(250);
    tone(SPEAKER,2093);
    delay(250);
    noTone(SPEAKER);
    analogWrite(RED_IN,0);
    analogWrite(BLUE_IN,0);
    analogWrite(YELLOW_IN,0);
    analogWrite(GREEN_IN,0);
    delay(500);
    }
    if(correct == 0) break;
    }
    }
    void PLAY(int current_stage){
    for(int i = 0; i <= current_stage; i++){
    switch(sequence[i]){
    case 0:
    pinMode(RED_IN, OUTPUT);
    analogWrite(RED_IN,1023);
    tone(SPEAKER,294);
    delay(500);
    analogWrite(RED_IN,0);
    noTone(SPEAKER);
    delay(500);
    break;
    case 1:
    pinMode(BLUE_IN, OUTPUT);
    analogWrite(BLUE_IN,1023);
    tone(SPEAKER,440);
    delay(500);
    analogWrite(BLUE_IN,0);
    noTone(SPEAKER);
    delay(500);
    break;
    case 2:
    pinMode(YELLOW_IN, OUTPUT);
    analogWrite(YELLOW_IN,1023);
    tone(SPEAKER,587);
    delay(500);
    analogWrite(YELLOW_IN,0);
    noTone(SPEAKER);
    delay(500);
    break;
    case 3:
    pinMode(GREEN_IN, OUTPUT);
    analogWrite(GREEN_IN,1023);
    tone(SPEAKER,880);
    delay(500);
    analogWrite(GREEN_IN,0);
    noTone(SPEAKER);
    delay(500);
    break;
    }
    }
    }
    void LISTEN(int current_stage){
    digitalWrite(RED, HIGH);
    digitalWrite(BLUE, HIGH);
    digitalWrite(YELLOW, HIGH);
    digitalWrite(GREEN, HIGH);
    pinMode(RED_IN, INPUT);
    pinMode(BLUE_IN, INPUT);
    pinMode(YELLOW_IN, INPUT);
    pinMode(GREEN_IN, INPUT);
    for (int i = 0; i <= current_stage; i++){
    int valR = 0, valB = 0, valY = 0, valG = 0;
    while(valR < 400 && valB < 400 && valY < 400 && valG < 400){
    valR = analogRead(RED_IN);
    valB = analogRead(BLUE_IN);
    valY = analogRead(YELLOW_IN);
    valG = analogRead(GREEN_IN);
    }
    delay(500);
    if(valR > 400) button_pressed[i] = 0;
    if(valB > 400) button_pressed[i] = 1;
    if(valY > 400) button_pressed[i] = 2;
    if(valG > 400) button_pressed[i] = 3;
    if (button_pressed[i] != sequence[i]){
    pinMode(RED_IN, OUTPUT);
    pinMode(BLUE_IN, OUTPUT);
    pinMode(YELLOW_IN, OUTPUT);
    pinMode(GREEN_IN, OUTPUT);
    analogWrite(RED_IN,1023);
    analogWrite(BLUE_IN,1023);
    analogWrite(YELLOW_IN,1023);
    analogWrite(GREEN_IN,1023);
    tone(SPEAKER,262);
    delay(250);
    tone(SPEAKER,175);
    delay(250);
    tone(SPEAKER,123);
    delay(250);
    noTone(SPEAKER);
    analogWrite(RED_IN,0);
    analogWrite(BLUE_IN,0);
    analogWrite(YELLOW_IN,0);
    analogWrite(GREEN_IN,0);
    delay(500);
    correct = 0;
    break;
    }
    else correct = 1;
    }
    }

    0
    Komalpreet
    Komalpreet

    Reply 3 months ago

    yes of course!! Hope this helps!!!


    const int RED = 10, BLUE = 11, YELLOW = 12, GREEN = 13;
    const int RED_IN = A3, BLUE_IN = A2, YELLOW_IN = A1, GREEN_IN = A0;
    const int SPEAKER = 3;
    int sequence[100];
    int correct = 0;
    int button_pressed[100];
    void setup(){
    pinMode(RED, OUTPUT);
    pinMode(BLUE, OUTPUT);
    pinMode(YELLOW, OUTPUT);
    pinMode(GREEN, OUTPUT);
    pinMode(SPEAKER, OUTPUT);
    digitalWrite(RED, LOW);
    digitalWrite(BLUE, LOW);
    digitalWrite(YELLOW, LOW);
    digitalWrite(GREEN, LOW);
    for(int siren_start = 0; siren_start < 5 ; siren_start++){
    tone(SPEAKER, 1047);
    delay(100);
    noTone(SPEAKER);
    delay(200);
    }
    delay(1000);
    randomSeed(analogRead(0));
    }
    void loop(){
    for(int current = 0; current < 100; current++){
    sequence[current] = random(4);
    PLAY(current);
    LISTEN(current);
    if(correct == 1) {
    analogWrite(RED_IN,1023);
    analogWrite(BLUE_IN,1023);
    analogWrite(YELLOW_IN,1023);
    analogWrite(GREEN_IN,1023);
    tone(SPEAKER,523);
    delay(250);
    tone(SPEAKER,1047);
    delay(250);
    tone(SPEAKER,2093);
    delay(250);
    noTone(SPEAKER);
    analogWrite(RED_IN,0);
    analogWrite(BLUE_IN,0);
    analogWrite(YELLOW_IN,0);
    analogWrite(GREEN_IN,0);
    delay(500);
    }
    if(correct == 0) break;
    }
    }
    void PLAY(int current_stage){
    for(int i = 0; i <= current_stage; i++){
    switch(sequence[i]){
    case 0:
    pinMode(RED_IN, OUTPUT);
    analogWrite(RED_IN,1023);
    tone(SPEAKER,294);
    delay(500);
    analogWrite(RED_IN,0);
    noTone(SPEAKER);
    delay(500);
    break;
    case 1:
    pinMode(BLUE_IN, OUTPUT);
    analogWrite(BLUE_IN,1023);
    tone(SPEAKER,440);
    delay(500);
    analogWrite(BLUE_IN,0);
    noTone(SPEAKER);
    delay(500);
    break;
    case 2:
    pinMode(YELLOW_IN, OUTPUT);
    analogWrite(YELLOW_IN,1023);
    tone(SPEAKER,587);
    delay(500);
    analogWrite(YELLOW_IN,0);
    noTone(SPEAKER);
    delay(500);
    break;
    case 3:
    pinMode(GREEN_IN, OUTPUT);
    analogWrite(GREEN_IN,1023);
    tone(SPEAKER,880);
    delay(500);
    analogWrite(GREEN_IN,0);
    noTone(SPEAKER);
    delay(500);
    break;
    }
    }
    }
    void LISTEN(int current_stage){
    digitalWrite(RED, HIGH);
    digitalWrite(BLUE, HIGH);
    digitalWrite(YELLOW, HIGH);
    digitalWrite(GREEN, HIGH);
    pinMode(RED_IN, INPUT);
    pinMode(BLUE_IN, INPUT);
    pinMode(YELLOW_IN, INPUT);
    pinMode(GREEN_IN, INPUT);
    for (int i = 0; i <= current_stage; i++){
    int valR = 0, valB = 0, valY = 0, valG = 0;
    while(valR < 400 && valB < 400 && valY < 400 && valG < 400){
    valR = analogRead(RED_IN);
    valB = analogRead(BLUE_IN);
    valY = analogRead(YELLOW_IN);
    valG = analogRead(GREEN_IN);
    }
    delay(500);
    if(valR > 400) button_pressed[i] = 0;
    if(valB > 400) button_pressed[i] = 1;
    if(valY > 400) button_pressed[i] = 2;
    if(valG > 400) button_pressed[i] = 3;
    if (button_pressed[i] != sequence[i]){
    pinMode(RED_IN, OUTPUT);
    pinMode(BLUE_IN, OUTPUT);
    pinMode(YELLOW_IN, OUTPUT);
    pinMode(GREEN_IN, OUTPUT);
    analogWrite(RED_IN,1023);
    analogWrite(BLUE_IN,1023);
    analogWrite(YELLOW_IN,1023);
    analogWrite(GREEN_IN,1023);
    tone(SPEAKER,262);
    delay(250);
    tone(SPEAKER,175);
    delay(250);
    tone(SPEAKER,123);
    delay(250);
    noTone(SPEAKER);
    analogWrite(RED_IN,0);
    analogWrite(BLUE_IN,0);
    analogWrite(YELLOW_IN,0);
    analogWrite(GREEN_IN,0);
    delay(500);
    correct = 0;
    break;
    }
    else correct = 1;
    }
    }