Build it step by step
0 of 5 donePlace the LEDs and buttons
Four LEDs in a square with a button beside each, same colour order as the code.
Wire the LEDs
D8 to D11 through 220 Ω each.
Wire the buttons
D2 to D5, other sides to GND.
Wire the buzzer
D12 to buzzer plus, minus to GND.
Play
Watch the first light, repeat it, and keep going. Your score prints in the serial monitor.
How do you build a simon memory game?
Four coloured LEDs and buttons play a growing sequence of lights and tones that you must repeat. Get one wrong and it plays the losing tune. You need Arduino Uno R3, LED 5 mm red, LED 5 mm green, LED 5 mm yellow, LED 5 mm blue, Resistor 220 Ω × 4, Tactile push button 12 mm with cap × 4, Passive buzzer, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 5 steps and about 75 minutes.
- Level
- Intermediate
- Time
- About 75 min
- Parts
- 10
Parts list
- Development BoardsBuyArduino Uno R3 × 1
- SemiconductorsBuyLED 5 mm red × 1
- SemiconductorsBuyLED 5 mm green × 1
- SemiconductorsBuyLED 5 mm yellow × 1
- OptoelectronicsBuyLED 5 mm blue × 1
- PassivesBuyResistor 220 Ω × 4
- SwitchesBuy
- Motors & ActuatorsBuyPassive buzzer × 1
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Uno D8 / D9 / D10 / D11 | 220 Ω, red / green / yellow / blue LED, GND | Lights |
| Buttons | Uno D2 / D3 / D4 / D5 to GND | One button next to each LED |
| Uno D12 | Passive buzzer + (− to GND) | Tones |
Code
Arduino IDE, board "Arduino Uno". No extra libraries.
Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
const int LED[4] = {8, 9, 10, 11}, BTN[4] = {2, 3, 4, 5}, BUZZ = 12;
const int TONE[4] = {330, 392, 494, 587};
byte seq[50]; int len = 0;
void flash(int i, int ms) {
digitalWrite(LED[i], HIGH); tone(BUZZ, TONE[i]); delay(ms);
digitalWrite(LED[i], LOW); noTone(BUZZ); delay(ms / 3);
}
int waitPress() {
unsigned long start = millis();
while (millis() - start < 4000) { // 4 s to answer
for (int i = 0; i < 4; i++) if (digitalRead(BTN[i]) == LOW) {
flash(i, 200); while (digitalRead(BTN[i]) == LOW) {}
return i;
}
}
return -1;
}
void lose() {
for (int f = 400; f > 100; f -= 30) { tone(BUZZ, f, 60); delay(70); }
Serial.print("Score: "); Serial.println(len - 1);
len = 0; delay(1000);
}
void setup() {
for (int i = 0; i < 4; i++) { pinMode(LED[i], OUTPUT); pinMode(BTN[i], INPUT_PULLUP); }
Serial.begin(9600);
randomSeed(analogRead(A0)); // floating pin = different game each time
}
void loop() {
seq[len++] = random(4);
int speed = max(150, 500 - len * 20); // faster as it grows
delay(600);
for (int i = 0; i < len; i++) flash(seq[i], speed);
for (int i = 0; i < len; i++) if (waitPress() != seq[i]) { lose(); return; }
if (len == 50) { Serial.println("You win!"); len = 0; }
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
Score: 0
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Start | One random light and tone |
| Correct repeat | The sequence grows by one and gets slightly faster |
| Wrong button or 4 s with no press | Falling tune, score printed, new game |
| Each button | Lights its own LED with its own tone |
If it does not work
Same sequence every game
Leave A0 unconnected: the random seed comes from it.
A button counts twice
The code waits for release. Check the button is not sticking.
Buzzer silent
Use a passive buzzer. An active one only clicks with tone().
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the simon memory game?
Arduino Uno R3, LED 5 mm red, LED 5 mm green, LED 5 mm yellow, LED 5 mm blue, Resistor 220 Ω × 4, Tactile push button 12 mm with cap × 4, Passive buzzer, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).
How long does the simon memory game take to build?
About 75 minutes for a intermediate maker, in 5 steps.
How do I know the simon memory game works?
Start: One random light and tone. Correct repeat: The sequence grows by one and gets slightly faster. Wrong button or 4 s with no press: Falling tune, score printed, new game.
Same sequence every game: what should I check?
Leave A0 unconnected: the random seed comes from it.
A button counts twice: what should I check?
The code waits for release. Check the button is not sticking.
Buzzer silent: what should I check?
Use a passive buzzer. An active one only clicks with tone().
