Instructables
In this Instructable I'll show you how to put together a very simple Simon Says Game using an Arduino Micro Controller. I first started this project back in 2010 and haven't picked it up again since. Much has changed in the world of Arduino ever since so some updates where need and will be discussed in a later step.

First we will cover how to set up the components on a breadboard. Then we will cover the Code used and how it all works. Then i'll show you how you can modify the code to customize the game to your liking.

Materials Needed:
  • Arduino (I used a Nove)
  • Bread Board
  • Jumper Wires
  • 4 different colored LEDs
  • 4 100 Ohm Resistors
  • 4 Push Buttons
  • Small Speaker
This is a very simple project that any first time Arduino developer can do. Teaching you how to implement multiple buttons and LEDs as well as adding sound to a project.
 
Remove these adsRemove these ads by Signing Up

Step 1: Hardware setup

For this setup we will be taking advantage of the internal pull up resistors that the Adruino Nove and newer have built in.

First you'll want to lay out your buttons on the bottom section of your Breadboard. We'll tie one lead of the buttons directly to ground. The other lead will be wired to the Arduino's Digital pins 2, 3, 4, and 5. I ran a wire to the top half of the board to keep the wires running from the board to the Arduino out of the way. 

Now we want to lay out the LEDs above the buttons. We'll plug the LEDs in with the switches so the Cathode is on the same strip as the side of the button that is tied to ground. Well arrange it so the Anode plugs in off to the side of the button. Now we'll take out 100 Ohm resistor and put it inline with the Anodeto the top section of the breadboard. Now we can connect a wire from the resistor to the Arduino.  The LEDs will be using Digital pins 8, 9, 10, and 11. So make sure the buttons and LED are lined up as follows:
  • Button on pin 2 with LED on pin 8
  • Button on pin 3 with LED on pin 9
  • Button on pin 4 with LED on pin 10
  • Button on pin 5 with LED on pin 11
Finally we connect the Speaker so that the black wire is to ground and the red wire is on pin 12 through. You can add a 10K potentiometer in line with the 1K resistor to give yourself a volume control. But i found the speaker is just load enough as is. Lets not forget to supply a ground wire between the Arduino and the breadboard. 
1-40 of 82Next »
jyo001 made it!4 months ago

I made this with my 8yo and she loves it! It's her first electronics project.

We're already discussing ways to customize it! :)

Thanks!

Photo on 7-5-14 at 5.27 PM.jpg
daaren made it!8 months ago

I made it with my kid (12 y.o.), and have fun both doing and playing with it.

Thank you very much for very detaled and precise instructions. I changed the source to match my Arduino ide version (I am still on 0022), a matter of minutes.

SimonSays.jpg
saidyalçın10 months ago

hi, thanks for project. I applayed this project. has appreciated tremendously. I'm waiting for the continuation of such projects.

http://youtu.be/iwfzyDovYZ4

Draco15210 months ago
I have problem when its compiling here is the error.I am making this at school.

Simon_Says\Tone.cpp.o: In function `Tone::begin(unsigned char)':
\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `Tone::begin(unsigned char)'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here
Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `Tone::_tone_pin_count'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here
Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer0_pin_port'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here
Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer0_pin_mask'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here
Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer1_pin_port'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here
Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer1_pin_mask'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here
Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer2_pin_port'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here
Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer2_pin_mask'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here
Simon_Says\Tone.cpp.o: In function `Tone::isPlaying()':
\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:371: multiple definition of `Tone::isPlaying()'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:371: first defined here
Simon_Says\Tone.cpp.o: In function `__vector_14':
\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:404: multiple definition of `__vector_14'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:404: first defined here
Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer0_toggle_count'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here
Simon_Says\Tone.cpp.o: In function `__vector_11':
\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:423: multiple definition of `__vector_11'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:423: first defined here
Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer1_toggle_count'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here
Simon_Says\Tone.cpp.o: In function `__vector_7':
\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:441: multiple definition of `__vector_7'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:441: first defined here
Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer2_toggle_count'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here
Simon_Says\Tone.cpp.o: In function `Tone::stop()':
\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:334: multiple definition of `Tone::stop()'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:334: first defined here
Simon_Says\Tone.cpp.o: In function `Tone::play(unsigned int, unsigned long)':
\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:191: multiple definition of `Tone::play(unsigned int, unsigned long)'
Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:191: first defined here
mpilchfamily (author)  Draco15210 months ago
Look through the other comments and review the section about how to install the library. Those errors are coming up because you don't have the tone library in the correct folder.

instructables is being glitchy so i dont know if you got my comment or not so here it is again. i got it to compile but it just keeps going through the tone and i cant find where to fix that.

mpilchfamily (author)  Draco15210 months ago

First double check your wiring. It's easy to put the buttons in 90 ndegrees off from they way they should be. If that happens then the arduino is going to see it as the button being held down and cuase problems.

how do I change the code so that after 10 rounds a particular event occurs? For example a pin is set to High?
mpilchfamily (author)  englishfire1 year ago
Change the correct line. Then after a successful round have the code compare that line with the number of rounds you want then have it do whatever it is you want it to do.
Thank you for your answer! Can you give me a hint where to find the correct line?
mpilchfamily (author)  englishfire1 year ago
It's noted as the Turn Counter. It tracks the number of turns or rounds that have been completed. Should be no need to change the counter at all. There is no limit set on the counter. All you have to do is after you see the line turn++ add your lines that will compare the turn value to the value you want and perform the actions you want if they match.
Turn++ if (turn >= 10) { digitalWrite(PIN 7, HIGH)}

Would this line be correct?

Maik
mpilchfamily (author)  englishfire1 year ago
YEs something like that would work fine.
Where can I change the number of rounds played before winning the game?
mpilchfamily (author)  englishfire1 year ago
Read through the code. The line responsible for tracking rounds is noted.
I modified your code and my family made a "Simon Says" Robot for my son's kindergarten family project, R is for Robot. Thanks for the instructable!!
RobotSimon.jpg
cloobird1 year ago
Hi! Newbie to the Arduino world, so please bear with me. I have followed all the steps and loaded the sketch, when I plug in the USB the lights and speaker just buzz continuously.

I am using an UNO. Please let me know if you see anything.
0.jpegphoto.JPG
mpilchfamily (author)  cloobird1 year ago
Sounds like you don't have the buttons oriented correctly. Make sure they are all oriented the right way and double check all connections. It's easy to place the buttons 90 degrees off the way they should be facing. Which causes the arduino to see the buttons as being held down constantly.
Thanks I will double check and try!
Hi! i have a problem...

https://lh6.googleusercontent.com/bWB1PdpWcJeOb8cWT5zFIJOf7jUcywoihaZAMDPgC1XQmKydXqmqkzrg6C2Z4P_Ynw=w1274-h496

i guess is a library problem. I instaled the tone library corectly like this http://arduino.cc/en/Guide/Libraries

I'm running on a Leonardo and the IDE is 1.0.5

Please help me! Thank you!
mpilchfamily (author)  corneltanase1 year ago
Your link is broken.

If it's a library problem you'll have problems trying to compile and upload the sketch. So make sure you have the library in the correct folder. There is a Libraries folder in the main Arduino folder where you launch the application from. There is also one in your My Documents folder where your sketches are saved too by default. Be sure the library is in both location just to be safe.
mpilchfamily (author) 1 year ago
As the instructions say on the previous step the pin wire was connected to pin 12. The notation is off here but if you want the speaker on pin 13 then put it there and change the sketch as needed.
jhsa1404671 year ago
Hi, I think you have a mistake here..
"speakerpin.begin(12); // speaker is on pin 13"
I think it should be 13 instead of 12??
I think you were correct about the orientation of my buttons. They were all oriented the same way, so they must have all been 90 degrees off. I rebuilt the circuit on my breadboard and it worked this time around. Thanks for the help and your quick responses!

Again, sorry about not being able to reply to your message. This comment system is goofy.
I am using an Arduino Mega 2560 with Arduino 1.0.4. I have had no trouble with the Tone library; I simply downloaded the .zip and unzipped the contents into the arduino-1.0.4/libaries folder and the tones work fine.

The game starts with the 13 notes defined in setup(). It then plays the 6 notes at the start of the turn. It will light up some combination of two to three lights (sequentially; one at a time) between ledpin[0] and ledpin[1] (pins 8 and 9), then makes the 3 low notes as if it received an invalid input. Then it will light up ledpin[2] (pin 10), again make the 3 low notes, light up ledpin[3] (pin 11), again make the 3 low notes, then start back at turn 0. It will play the 6 notes at the beginning of the turn and again sequentially light up two to three of the lower two LEDs. None of this allows for any input, and it simply repeats.

Any suggestions? I'd be happy to post pictures or video to an external site.

P.S. fgonzalez14 is also correct about the system not allowing replies. My apologies for another thread.
mpilchfamily (author)  Eclecticist1 year ago
Sounds like you have a wire crossed. Or it may be that a button is not plugged in correctly. If your using similar buttons to what i used than you may have one 90 degrees off causing it to short and trigger a button press constantly. With the tight confines of the setup it is very easy to have something crossed or misplaced.

Try taking the LEDs out of the mix and using just the buttons. Disconnect the wires, resistors and the LEDs completely from the board. Then go threw each button, one at a time and look at them closely. They should be oriented so that the pins are coming out the top and bottom of the part and your breadboard is situated length wise across your work area as you see it in the pictures above. That is why i tried to give a clear close up of the buttons in the first image. It's very easy to get them oriented wrong.
@mpilchfamily: I second fgonzalez14's observation. I have been rewriting the code myself because the original code loops through the game without giving the user a chance for input. My wiring is 100% correct. All components work correctly. My libraries are set up correctly. I'm not new to Arduino. This code simply didn't work out for me, and it sounds like I'm not the only one. I may come back to post my code when I write it myself, but I'll be interested to see if a solution can be identified.
mpilchfamily (author)  Eclecticist1 year ago
Having rebuilt the project on my Arduino Nove and using Arduino 1.0.4 i find everything works as it should. I had trouble at first with the Tone library not working. So i placed it in both the Arduino/Library folder on my desktop where i keep the IDE and the Arduino/Library folder that sits in the My Documents Folder. Be sure to place the library before starting up the IDE. The sketch compiles just fine and the game runs as it should on the arduino.
The code that I have placed is as follows, I did it four times(copied and paste) to my arduino and all four time it has done the same.

/*Simon Says game. Now with sound effects.

Originaly made by Robert Spann
Code trimmed and sound effects added by digimike

Buttons are to be set on there designated pins without pull down resistors
and connected to ground rather then +5.
*/
#include
Tone speakerpin;
int starttune[] = {NOTE_C4, NOTE_F4, NOTE_C4, NOTE_F4, NOTE_C4, NOTE_F4, NOTE_C4, NOTE_F4, NOTE_G4, NOTE_F4, NOTE_E4, NOTE_F4, NOTE_G4};
int duration2[] = {100, 200, 100, 200, 100, 400, 100, 100, 100, 100, 200, 100, 500};
int note[] = {NOTE_C4, NOTE_C4, NOTE_G4, NOTE_C5, NOTE_G4, NOTE_C5};
int duration[] = {100, 100, 100, 300, 100, 300};
boolean button[] = {2, 3, 4, 5}; //The four button input pins
boolean ledpin[] = {8, 9, 10, 11}; // LED pins
int turn = 0; // turn counter
int buttonstate = 0; // button state checker
int randomArray[100]; //Intentionally long to store up to 100 inputs (doubtful anyone will get this far)
int inputArray[100];


void setup()
{
Serial.begin(9600);
speakerpin.begin(12); // speaker is on pin 13

for(int x=0; x<4; x++) // LED pins are outputs
{
pinMode(ledpin[x], OUTPUT);
}

for(int x=0; x<4; x++)
{
pinMode(button[x], INPUT); // button pins are inputs
digitalWrite(button[x], HIGH); // enable internal pullup; buttons start in high position; logic reversed
}

randomSeed(analogRead(0)); //Added to generate "more randomness" with the randomArray for the output function
for (int thisNote = 0; thisNote < 13; thisNote ++) {
// play the next note:
speakerpin.play(starttune[thisNote]);
// hold the note:
if (thisNote==0 || thisNote==2 || thisNote==4 || thisNote== 6)
{
digitalWrite(ledpin[0], HIGH);
}
if (thisNote==1 || thisNote==3 || thisNote==5 || thisNote== 7 || thisNote==9 || thisNote==11)
{
digitalWrite(ledpin[1], HIGH);
}
if (thisNote==8 || thisNote==12)
{
digitalWrite(ledpin[2], HIGH);
}
if (thisNote==10)
{
digitalWrite(ledpin[3], HIGH);
}
delay(duration2[thisNote]);
// stop for the next note:
speakerpin.stop();
digitalWrite(ledpin[0], LOW);
digitalWrite(ledpin[1], LOW);
digitalWrite(ledpin[2], LOW);
digitalWrite(ledpin[3], LOW);
delay(25);
}
delay(1000);
}

void loop()
{
for (int y=0; y<=99; y++)
{
//function for generating the array to be matched by the player
digitalWrite(ledpin[0], HIGH);
digitalWrite(ledpin[1], HIGH);
digitalWrite(ledpin[2], HIGH);
digitalWrite(ledpin[3], HIGH);

for (int thisNote = 0; thisNote < 6; thisNote ++) {
// play the next note:
speakerpin.play(note[thisNote]);
// hold the note:
delay(duration[thisNote]);
// stop for the next note:
speakerpin.stop();
delay(25);
}

digitalWrite(ledpin[0], LOW);
digitalWrite(ledpin[1], LOW);
digitalWrite(ledpin[2], LOW);
digitalWrite(ledpin[3], LOW);
delay(1000);

for (int y=turn; y <= turn; y++)
{ //Limited by the turn variable
Serial.println(""); //Some serial output to follow along
Serial.print("Turn: ");
Serial.print(y);
Serial.println("");
randomArray[y] = random(1, 5); //Assigning a random number (1-4) to the randomArray[y], y being the turn count
for (int x=0; x <= turn; x++)
{
Serial.print(randomArray[x]);

for(int y=0; y<4; y++)
{

if (randomArray[x] == 1 && ledpin[y] == 8)
{ //if statements to display the stored values in the array
digitalWrite(ledpin[y], HIGH);
speakerpin.play(NOTE_G3, 100);
delay(400);
digitalWrite(ledpin[y], LOW);
delay(100);
}

if (randomArray[x] == 2 && ledpin[y] == 9)
{
digitalWrite(ledpin[y], HIGH);
speakerpin.play(NOTE_A3, 100);
delay(400);
digitalWrite(ledpin[y], LOW);
delay(100);
}

if (randomArray[x] == 3 && ledpin[y] == 10)
{
digitalWrite(ledpin[y], HIGH);
speakerpin.play(NOTE_B3, 100);
delay(400);
digitalWrite(ledpin[y], LOW);
delay(100);
}

if (randomArray[x] == 4 && ledpin[y] == 11)
{
digitalWrite(ledpin[y], HIGH);
speakerpin.play(NOTE_C4, 100);
delay(400);
digitalWrite(ledpin[y], LOW);
delay(100);
}
}
}
}
input();
}
}



void input() { //Function for allowing user input and checking input against the generated array

for (int x=0; x <= turn;)
{ //Statement controlled by turn count

for(int y=0; y<4; y++)
{

buttonstate = digitalRead(button[y]);

if (buttonstate == LOW && button[y] == 2)
{ //Checking for button push
digitalWrite(ledpin[0], HIGH);
speakerpin.play(NOTE_G3, 100);
delay(200);
digitalWrite(ledpin[0], LOW);
inputArray[x] = 1;
delay(250);
Serial.print(" ");
Serial.print(1);
if (inputArray[x] != randomArray[x]) { //Checks value input by user and checks it against
fail(); //the value in the same spot on the generated array
} //The fail function is called if it does not match
x++;
}
if (buttonstate == LOW && button[y] == 3)
{
digitalWrite(ledpin[1], HIGH);
speakerpin.play(NOTE_A3, 100);
delay(200);
digitalWrite(ledpin[1], LOW);
inputArray[x] = 2;
delay(250);
Serial.print(" ");
Serial.print(2);
if (inputArray[x] != randomArray[x]) {
fail();
}
x++;
}

if (buttonstate == LOW && button[y] == 4)
{
digitalWrite(ledpin[2], HIGH);
speakerpin.play(NOTE_B3, 100);
delay(200);
digitalWrite(ledpin[2], LOW);
inputArray[x] = 3;
delay(250);
Serial.print(" ");
Serial.print(3);
if (inputArray[x] != randomArray[x]) {
fail();
}
x++;
}

if (buttonstate == LOW && button[y] == 5)
{
digitalWrite(ledpin[3], HIGH);
speakerpin.play(NOTE_C4, 100);
delay(200);
digitalWrite(ledpin[3], LOW);
inputArray[x] = 4;
delay(250);
Serial.print(" ");
Serial.print(4);
if (inputArray[x] != randomArray[x])
{
fail();
}
x++;
}
}
}
delay(500);
turn++; //Increments the turn count, also the last action before starting the output function over again
}

void fail() { //Function used if the player fails to match the sequence

for (int y=0; y<=2; y++)
{ //Flashes lights for failure

digitalWrite(ledpin[0], HIGH);
digitalWrite(ledpin[1], HIGH);
digitalWrite(ledpin[2], HIGH);
digitalWrite(ledpin[3], HIGH);
speakerpin.play(NOTE_G3, 300);
delay(200);
digitalWrite(ledpin[0], LOW);
digitalWrite(ledpin[1], LOW);
digitalWrite(ledpin[2], LOW);
digitalWrite(ledpin[3], LOW);
speakerpin.play(NOTE_C3, 300);
delay(200);
}
delay(500);
turn = -1; //Resets turn value so the game starts over without need for a reset button
mpilchfamily (author)  fgonzalez141 year ago
Once again... Check your wiring. It is very easy to get things mixed up.
It does not allow me to reply to the previous post so I created a new thread once again.

I was able to fix that problem but now that I have completed it, it only does the music but does not allow me to actually play the game. Anyway to correct this?
mpilchfamily (author)  fgonzalez141 year ago
Double check all your connections and check the code. If you have uploaded it without making any changes then it will all work. Chances are you don't have the wiring done right.
(removed by author or community request)
mpilchfamily (author)  fgonzalez141 year ago
Are you only seeing errors for the speakerpin and none for notes? These are the kinds of things you see when the library isn't in the correct folder. Make sure you have put it in the correct folder. If the IDE is using a different Arduino folder that is in a different location on your HDD then you'll get these errors. Double check you have the library in the library folder that is in the arduino folder.
I am new to arduino and was wondering where to install the tone library?
Verinix1 year ago
Hello! Really enjoying the project, I almost have it working. My one issue is concerning the LEDS and when they are on/off. For example, say the LED/button sequence you have is press is 1, 2, 3. LED 1 would light up first, then LED 2, then LED 3. Instead, however, my LEDS turn on as follows: LED 2 and 3 light up first, then 1 and 3, and then 1 and 2. Essentially, the inverse is appearing rather than just the single LED. Any advice as to how to fix this? Thanks!
mpilchfamily (author)  Verinix1 year ago
Double check your wiring.
rfilomeno1 year ago
Great work, thank you very much, it worked perfectly straight away.
I am just wondering if there is a way of increasing speed of sequence once game progresses.
Planning to use your code for a uni project and will definitely credit code to you.
tks again
mpilchfamily (author)  rfilomeno1 year ago
Play with the delays in the void loop where it's checking the array and playing the right notes and flashing the right LEDs. Use the last delay in each if statement. Instead of having the delay set to 100 you can set a variable for the delay and increase of decrease the delay as the game progresses.
@mpilchfamily

Yeah i have now thank you, the instructions i was given on how to install to the library were far from clear, code is working fine and i will be assembling tommorow. Using this for a university project, Product Design
1-40 of 82Next »