loading

Step 2: The Sketch

The sketch was originally made by Robert Spann back in 2009. I used an earlier version of his sketch since i didn't like the way he integrated sound in later versions of the sketch. To give the game sound i decided to use the Tone.h Library. The Library hasn't been updated since the release of Arduino 1.0, so i went ahead and updated it to be compatible with Arduino 1.0. In doing so i cut out any backwards compatibility with older IDEs. So if your running an older version of the IDE then used the link in the next step to download the original library. I've attached a copy of the updated library on this page. So be sure to download it and place it in your Arduino/Libraries folder or the sketch will not compile under Arduino 1.0.

Here is the Sketch. A file of the sketch is also attached. If there are any questions about it please let me know. 
/*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.h>
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
}
<p>It works great!</p>
<p>Hello, </p><p>I made the connections, copy/pasted the tone folder under libraries folder, uploaded the code into arduino uno(chinese clone) but nothing happened. </p><p>I checked the connections multiple times. I even asked someone else to check the connections but no fault is found.</p><p>There is only one warning when I upload the code:</p><p>simon_says_audio_ino:15:31: warning: narrowing conversion of '2' from 'int' to 'boolean' inside { } [-Wnarrowing]</p><p>This error repeats for every pin(2,3,4,5,8,9,10,11). Serial monitor gives this:</p><p>Turn: 0</p><p>2</p><p>What am I doing wrong?</p>
<p>Change from &quot;Boolean&quot; to &quot;int&quot; on lines 15 &amp; 16</p>
<p>Yes, it worked! I made it. Kids loved it.</p>
<p>Hello,</p><p>I've been trying for hours to get this to work, tried 3 different rewires, rotated switches. The code compiles fine, Serial starts and I get the tone through the speaker but no LEDs or input from buttons in Serial. I checked all the comments and tried them but no luck. So i'm finally posting for help, I have two pics up I'm almost certain it's wiring but I can't find any of the problems. Any help would be greatly appreciated, thank you</p>
<p>Well, I couldn't do my version so I may not be the one to answer your question as it should be but if you look at the 1st step/last photo, there is an extra cable for pin 13. </p><p>So if you add that final connection it may work. Or it may not. I couldn't manage what was my problem either:)</p>
<p>Thanks for the try but unfortunately that is just the ground connection I already established, but I have solved it!</p><p>Change from &quot;Boolean&quot; to &quot;int&quot; on lines 15 &amp; 16 worked for me</p><p>LED PROBLEMS with Arduino Starter Kit SOLVED:</p><p>I spent 3 days trying to get this to work and have finally solved it. My big problem was my breadboard wouldn't hold my components and poor connections prevented my LEDs from working. I am using the official arduino starter kit (which is one of the best by the way) and it turns out the metal plates underneath the connect points bend from overuse. </p><p>Solution: <a href="http://forum.arduino.cc/index.php?topic=163989.0" rel="nofollow">http://forum.arduino.cc/index.php?topic=163989.0</a></p><p>Also spacing out components as much as possible on the breadboard helped too</p><p>I also bought new buttons: <a href="https://www.sparkfun.com/products/10302" rel="nofollow">https://www.sparkfun.com/products/10302</a></p><p>but I am fairly certain the breadboard trick will work with anyone having LED problems</p><p>Its refreshing to know I can blame this one on the tech and not myself!</p><p>Thanks for a great tutorial!</p>
<p>i have a program while compiling...please help me bro....the error is shown below</p><p>sketch\Tone.cpp:26:20: fatal error: wiring.h: No such file or directory</p><p> #include &lt;wiring.h&gt;</p><p> ^</p><p>compilation terminated.</p><p>exit status 1</p><p>Error compiling.</p><p> This report would have more information with</p><p> &quot;Show verbose output during compilation&quot;</p><p> enabled in File &gt; Preferences.</p>
<p>Read through all the other comments. This question has been answered several times already. Bottom line you don't have the tone library installed correctly.</p>
I am new to arduino and was wondering where to install the tone library?
<p>C:\Program Files (x86)\Arduino\libraries</p>
<p>Nice project. I added a score system (at the end of the game all led blinks and a note is played, once for each point) :)</p>
it was so fun :) i use 45mm arcade buttons and change buttons and leds from boolean to int in code, a then everything works !
<p>Hey brother, in order to connect the 45mm which jumpers i need to use? can you maybe post a screenshot so i could check out how they are connected?</p>
<p>Should be easy to figure out. The button has pins for the button itself and for it's internal LED. Look at the data sheet for the buttons to determine anode and cathode of the LED and you should be all set. Of course one of the button pins goes to ground while the other goes to the input pin on the arduino. </p>
<p>Thank you taking the time! :))</p>
<p>Superb...</p>
<p>Hello.</p><p>Also the LEDs are not working. When I try each LED and Button separately then they work. In the program only the speaker is working.</p><p>What could be the problem?</p><p>I work with an Arduino UNO.</p><p>Thanks for your help</p>
<p>You're asking the same question many others have had and the answers are outlined in the instructable and reiterated in the below replies. </p>
<p>Yes i know.</p><p>But because the LEDs and the buttons are working when i use another sketch I thougt that maybe there is another problem.</p>
<p>As evident by the examples shown below the code works. So chances are it's user error in wiring. make sure you have things wired to the correct pins. Beyond that there isn't much more help i can give. </p>
<p>Thanks.</p><p>I gonna try again.</p>
<p>i've tried to do this but why is it the LED is not working,..after uploading the program, only the speaker is working,..need help thanks!!!</p>
<p>Most common issue is the buttons are not connected correctly, so at least one button is connected as if it's being pressed constantly. Causing the system to cycle from the intro music, to the first sequence, then it plays the invalid button press and then plays the fail music and starts over again. </p>
<p>I made one of these back on Halloween based on your instructable, and built it in to a foam pumpkin. I also added in a score keeper. All running off an arduino micro. Here's a video of it: https://www.youtube.com/watch?v=a8hAbwgQ0rg</p>
<p>Hey so I've run into some problems with the code, it looks like a lot of people have the same error but I can't fix it no matter what I've done. The errors I'm getting are</p><p>Simon_Says:10: error: 'Tone' does not name a type</p><p>Simon_Says:11: error: 'NOTE_C4' was not declared in this scope</p><p>Simon_Says:11: error: 'NOTE_F4' was not declared in this scope</p><p>Simon_Says:11: error: 'NOTE_C4' was not declared in this scope</p><p>Simon_Says:11: error: 'NOTE_F4' was not declared in this scope</p><p>Simon_Says:11: error: 'NOTE_C4' was not declared in this scope</p><p>Simon_Says:11: error: 'NOTE_F4' was not declared in this scope</p><p>Simon_Says:11: error: 'NOTE_C4' was not declared in this scope</p><p>Simon_Says:11: error: 'NOTE_F4' was not declared in this scope</p><p>Simon_Says:11: error: 'NOTE_G4' was not declared in this scope</p><p>Simon_Says:11: error: 'NOTE_F4' was not declared in this scope</p><p>Simon_Says:11: error: 'NOTE_E4' was not declared in this scope</p><p>Simon_Says:11: error: 'NOTE_F4' was not declared in this scope</p><p>Simon_Says:11: error: 'NOTE_G4' was not declared in this scope</p><p>Simon_Says:13: error: 'NOTE_C4' was not declared in this scope</p><p>Simon_Says:13: error: 'NOTE_C4' was not declared in this scope</p><p>Simon_Says:13: error: 'NOTE_G4' was not declared in this scope</p><p>Simon_Says:13: error: 'NOTE_C5' was not declared in this scope</p><p>Simon_Says:13: error: 'NOTE_G4' was not declared in this scope</p><p>Simon_Says:13: error: 'NOTE_C5' was not declared in this scope</p><p>Simon_Says.ino: In function 'void setup()':</p><p>Simon_Says:26: error: 'speakerpin' was not declared in this scope</p><p>Simon_Says.ino: In function 'void loop()':</p><p>Simon_Says:84: error: 'speakerpin' was not declared in this scope</p><p>Simon_Says:115: error: 'speakerpin' was not declared in this scope</p><p>Simon_Says:115: error: 'NOTE_G3' was not declared in this scope</p><p>Simon_Says:124: error: 'speakerpin' was not declared in this scope</p><p>Simon_Says:124: error: 'NOTE_A3' was not declared in this scope</p><p>Simon_Says:133: error: 'speakerpin' was not declared in this scope</p><p>Simon_Says:133: error: 'NOTE_B3' was not declared in this scope</p><p>Simon_Says:142: error: 'speakerpin' was not declared in this scope</p><p>Simon_Says:142: error: 'NOTE_C4' was not declared in this scope</p><p>Simon_Says.ino: In function 'void input()':</p><p>Simon_Says:169: error: 'speakerpin' was not declared in this scope</p><p>Simon_Says:169: error: 'NOTE_G3' was not declared in this scope</p><p>Simon_Says:184: error: 'speakerpin' was not declared in this scope</p><p>Simon_Says:184: error: 'NOTE_A3' was not declared in this scope</p><p>Simon_Says:200: error: 'speakerpin' was not declared in this scope</p><p>Simon_Says:200: error: 'NOTE_B3' was not declared in this scope</p><p>Simon_Says:216: error: 'speakerpin' was not declared in this scope</p><p>Simon_Says:216: error: 'NOTE_C4' was not declared in this scope</p><p>Simon_Says.ino: In function 'void fail()':</p><p>Simon_Says:244: error: 'speakerpin' was not declared in this scope</p><p>Simon_Says:244: error: 'NOTE_G3' was not declared in this scope</p><p>Simon_Says:250: error: 'NOTE_C3' was not declared in this scope</p><p>I have Arduino 1.0.6. and I downloaded the tone files and they are in the arduino libraries folder. I hope you can help!</p>
<p>All those errors relate to the tone library. Be it in the wrong folder or a change in the IDE now conflicts with the library itself. The change over to 1.0 changed things requiring the tone library to be updated. So it should be fully compatible with 1.0.6. Keep in mind if you store you sketches in another location the IDE creates a library folder there as well. typically in your My Documents folder. So be sure a copy of the library is there as well. </p>
<p>I made this with my 8yo and she loves it! It's her first electronics project.</p><p>We're already discussing ways to customize it! :)</p><p>Thanks!</p>
<p>I made it with my kid (12 y.o.), and have fun both doing and playing with it.</p><p>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.</p>
<p>hi, thanks for project. I applayed this project. has appreciated tremendously. I'm waiting for the continuation of such projects. </p><p>http://youtu.be/iwfzyDovYZ4</p>
I have problem when its compiling here is the error.I am making this at school. <br> <br>Simon_Says\Tone.cpp.o: In function `Tone::begin(unsigned char)': <br>\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `Tone::begin(unsigned char)' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here <br>Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `Tone::_tone_pin_count' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here <br>Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer0_pin_port' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here <br>Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer0_pin_mask' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here <br>Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer1_pin_port' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here <br>Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer1_pin_mask' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here <br>Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer2_pin_port' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here <br>Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer2_pin_mask' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here <br>Simon_Says\Tone.cpp.o: In function `Tone::isPlaying()': <br>\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:371: multiple definition of `Tone::isPlaying()' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:371: first defined here <br>Simon_Says\Tone.cpp.o: In function `__vector_14': <br>\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:404: multiple definition of `__vector_14' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:404: first defined here <br>Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer0_toggle_count' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here <br>Simon_Says\Tone.cpp.o: In function `__vector_11': <br>\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:423: multiple definition of `__vector_11' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:423: first defined here <br>Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer1_toggle_count' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here <br>Simon_Says\Tone.cpp.o: In function `__vector_7': <br>\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:441: multiple definition of `__vector_7' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:441: first defined here <br>Simon_Says\Tone.cpp.o:\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:104: multiple definition of `timer2_toggle_count' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:104: first defined here <br>Simon_Says\Tone.cpp.o: In function `Tone::stop()': <br>\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:334: multiple definition of `Tone::stop()' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:334: first defined here <br>Simon_Says\Tone.cpp.o: In function `Tone::play(unsigned int, unsigned long)': <br>\\40c\users\627805\documents\Arduino\libraries\Simon_Says/Tone.cpp:191: multiple definition of `Tone::play(unsigned int, unsigned long)' <br>Tone.cpp.o:C:\Users\627805\AppData\Local\Temp\build5323159694636483711.tmp/Tone.cpp:191: first defined here
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.
<p>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.</p>
<p>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. </p>
how do I change the code so that after 10 rounds a particular event occurs? For example a pin is set to High?
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. <br>
Thank you for your answer! Can you give me a hint where to find the correct line?
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 &gt;= 10) { digitalWrite(PIN 7, HIGH)}<br><br>Would this line be correct?<br><br>Maik
YEs something like that would work fine.
Where can I change the number of rounds played before winning the game? <br>
Read through the code. The line responsible for tracking rounds is noted.
I modified your code and my family made a &quot;Simon Says&quot; Robot for my son's kindergarten family project, R is for Robot. Thanks for the instructable!!
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. <br> <br>I am using an UNO. Please let me know if you see anything.
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... <br> <br>https://lh6.googleusercontent.com/bWB1PdpWcJeOb8cWT5zFIJOf7jUcywoihaZAMDPgC1XQmKydXqmqkzrg6C2Z4P_Ynw=w1274-h496 <br> <br>i guess is a library problem. I instaled the tone library corectly like this http://arduino.cc/en/Guide/Libraries <br> <br>I'm running on a Leonardo and the IDE is 1.0.5 <br> <br>Please help me! Thank you!
Your link is broken. <br> <br>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.
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.

About This Instructable

62,568views

66favorites

License:

Bio: I'm a jack of all trades and a master of none. I like to tweak, mod and improvise whenever possible!
More by mpilchfamily:Universal USB Power Supply Kit FM Bug Detector Kit FM Listening Bug 
Add instructable to: