Delivery throughout Europe

Ordered before 16:00 = Shipped today

Fast delivery with DHL

XNUMX days return *


Country

In this Arduino project I show you how to make the game Simon says with an Arduino.
Simon Says is a game where you have 4 Lights that are each connected to a push button. In the beginning one light will come on.
Then you press the corresponding button. If you have pressed the right button, the same and a next light will come on. Every time you get it right a light comes on, every time a light comes on you go up one round. In this project you can adjust how many rounds you want to play.
If you fail a sequence you have lost the game and start over. A random order starts every time the game is played again.

  • Level - Beginner 30% 30%
  • Duration - 20/30 Min 35% 35%
  • Costs - € 36,87 euros complete 30% 30%

Step 1: Requirements

1X Arduino UNO

1X breadboard

18X jumper wires

4X push buttons

1X green, blue, yellow and red LED light

4X 220 ohm resistor

Step 2: Building and Wiring

Now we are going to assemble Simon Says.

You start with the plus and minus of the Arduino on the plus and minus of the breadboard to connect.

Then you put the LED lights in the board. If you have done that, place a 220 ohm resistor on the plus side with each LED light, this is the longest pin.
Then you go from the min pin of the LED lights to their own push button.

When you have done that you go from every button of the pin that is vertically from the minus at each led (see Fritzing diagram) to the minus of the breadboard† Then you go from every button at the pin that is diagonal from the minus of the led to the plus of the breadboard.

Then add a cable from the diagonal pin to the minus of the LEDs. A2 = red, A3 = green, A1 = yellow and blue = A0.

Finally, a cable goes from the other side of the resistor to the I / O pins. From red to pin 3, from green to pin 2 from yellow to pin 4 and from blue to pin 5.

Step 3: Programming

 

Now that you're done wiring the Arduino you can do it board start programming.

You can copy the code below into your Arduino program. We recommend typing the entire code as you learn more from that.
In the code itself you can adjust how quickly the lights go on and off and how much that time decreases per good combination. This way you can make the game more and more difficult.

 

const int MAX_LVL = 10;

int order [MAX_LVL];

int eigen_volg [MAX_LVL];

int LVL = 1;

int speed = 1000;

 

void setup () {

  pinMode (A0, INPUT);

  pinMode (A1, INPUT);

  pinMode (A2, INPUT);

  pinMode (A3, INPUT);

  pinMode (2, OUTPUT);

  pinMode (3, OUTPUT);

  pinMode (4, OUTPUT);

  pinMode (5, OUTPUT);

  digitalWrite (2, LOW);

  digitalWrite (3, LOW);

  digitalWrite (4, LOW);

  digitalWrite (5, LOW);

}

 

void loop () {

  if (LVL == 1)

  generate_follow ();

  if (digitalRead (A0) == HIGH && digitalRead (A3) == HIGH || LVL! = 1) {

    show_volg ();

    get_volg ();

  }

}

 

void show_volg () {

  digitalWrite (2, LOW);

  digitalWrite (3, LOW);

  digitalWrite (4, LOW);

  digitalWrite (5, LOW);

  for (int i = 0; i <LVL; i ++) {

    digitalWrite (order [i], HIGH);

    delay (speed);

    digitalWrite (order [i], LOW);

    delay (200);

  }

}

 

void get_volg () {

  int flag = 0;

  for (int i = 0; i <LVL; i ++) {

    flag = 0;

    while (flag == 0) {

      if (digitalRead (A0) == LOW) {

        digitalWrite (5, HIGH);

        eigen_volg [i] = 5;

        flag = 1;

        delay (200);

        if (eigen_volg [i]! = order [i]) {

          wrong_follow ();

          return;

        }

        digitalWrite (5, LOW);

      }

      if (digitalRead (A1) == LOW) {

        digitalWrite (4, HIGH);

        eigen_volg [i] = 4;

        flag = 1;

        delay (200);

        if (eigen_volg [i]! = order [i]) {

          wrong_follow ();

          return;

        }

        digitalWrite (4, LOW);

      }

      if (digitalRead (A2) == LOW) {

        digitalWrite (3, HIGH);

        eigen_volg [i] = 3;

        flag = 1;

        delay (200);

        if (eigen_volg [i]! = order [i]) {

          wrong_follow ();

          return;

        }

        digitalWrite (3, LOW);

      }

      if (digitalRead (A3) == LOW) {

        digitalWrite (2, HIGH);

        eigen_volg [i] = 2;

        flag = 1;

        delay (200);

        if (eigen_volg [i]! = order [i]) {

          wrong_follow ();

          return;

        }

        digitalWrite (2, LOW);

      }

    }

  }

  good_follow ();

}

 

void generate_follow () {

  randomSeed (millis ());

  for (int i = 0; i <MAX_LVL; i ++) {

    order [i] = random (2, 6);

  }

}

 

void wrong_follow () {

  for (int i = 0; i <3; i ++) {

    digitalWrite (2, HIGH);

    digitalWrite (3, HIGH);

    digitalWrite (4, HIGH);

    digitalWrite (5, HIGH);

    delay (250);

    digitalWrite (2, LOW);

    digitalWrite (3, LOW);

    digitalWrite (4, LOW);

    digitalWrite (5, LOW);

    delay (250);

  }

  LVL = 1;

  speed = 1000;

}

 

void good_follow () {

  digitalWrite (2, LOW);

  digitalWrite (3, LOW);

  digitalWrite (4, LOW);

  digitalWrite (5, LOW);

  delay (250);

  digitalWrite (2, HIGH);

  digitalWrite (3, HIGH);

  digitalWrite (4, HIGH);

  digitalWrite (5, HIGH);

  delay (500);

  digitalWrite (2, LOW);

  digitalWrite (3, LOW);

  digitalWrite (4, LOW);

  digitalWrite (5, LOW);

  delay (250);

  if (LVL <MAX_LVL);

  LVL ++;

  speed - = 100;

}

Your Simon Says game should now look something like the video below.
Every game is different, so it can be hours of fun!

 

The rating of www.elektronicavoorjou.nl at WebwinkelKeur Reviews is 9.3/10 based on 4970 reviews.