Table of Contents
- Introduction
- Components and Hardware Setup
- Wiring Diagram and Connections
- Complete Code with Explanation
- Customization and Improvements
- Troubleshooting Common Issues
- Advanced Features and Extensions
- Frequently Asked Questions
- Conclusion
Introduction
The Arduino Simon Says game is one of the best beginner projects for learning Arduino programming. It teaches arrays, random numbers, loops, input handling, timing, and state machines — all wrapped in a fun, interactive game. You will build the classic memory game where the Arduino plays a sequence of LED flashes and the player must repeat the sequence by pressing the corresponding buttons.
This project requires only 4 LEDs, 4 buttons, a piezo buzzer, and an Arduino — components typically included in starter kits. The total cost is under ₹100 if you already have an Arduino board.
Components and Hardware Setup
- Arduino Uno or Nano
- 4 LEDs (red, green, blue, yellow)
- 4 push buttons
- 4x 220 ohm resistors (for LEDs)
- 1 piezo buzzer
- Breadboard and jumper wires
Wiring Diagram and Connections
// LED pins: 8 (red), 9 (green), 10 (blue), 11 (yellow)
// Button pins: 2, 3, 4, 5 (with INPUT_PULLUP)
// Buzzer: pin 7
const int ledPins[] = {8, 9, 10, 11};
const int btnPins[] = {2, 3, 4, 5};
const int tones[] = {262, 330, 392, 523}; // C4, E4, G4, C5
const int BUZZER = 7;
Complete Code with Explanation
#define MAX_LEVEL 100
int sequence[MAX_LEVEL];
int level = 0;
void setup() {
for (int i=0; i<4; i++) { pinMode(ledPins[i], OUTPUT); pinMode(btnPins[i], INPUT_PULLUP); }
pinMode(BUZZER, OUTPUT);
randomSeed(analogRead(A0));
startAnimation();
}
void loop() {
// Add new step to sequence
sequence[level] = random(4);
level++;
// Play sequence
for (int i=0; i<level; i++) {
flashLED(sequence[i], 400);
delay(200);
}
// Get player input
for (int i=0; i<level; i++) {
int btn = waitForButton();
if (btn != sequence[i]) { gameOver(); return; }
flashLED(btn, 200);
}
// Success - brief pause before next round
delay(500);
}
void flashLED(int idx, int duration) {
digitalWrite(ledPins[idx], HIGH);
tone(BUZZER, tones[idx], duration);
delay(duration);
digitalWrite(ledPins[idx], LOW);
}
int waitForButton() {
while (true) {
for (int i=0; i<4; i++) {
if (digitalRead(btnPins[i]) == LOW) {
delay(50); // Debounce
while (digitalRead(btnPins[i]) == LOW); // Wait release
return i;
}
}
}
}
void gameOver() {
// Flash all LEDs and play sad tone
for (int j=0; j<3; j++) {
for (int i=0; i<4; i++) digitalWrite(ledPins[i], HIGH);
tone(BUZZER, 100, 300); delay(300);
for (int i=0; i<4; i++) digitalWrite(ledPins[i], LOW);
delay(300);
}
level = 0; delay(1000);
}
void startAnimation() {
for (int i=0; i<4; i++) { flashLED(i, 150); }
}
Customization and Improvements
- Add speed increase: reduce delay as levels increase for more challenge
- Add score display with 7-segment LED or OLED screen
- Store high score in EEPROM
- Add two-player mode where players take turns
- Add a timeout — if the player takes too long, game over
Troubleshooting Common Issues
- Buttons register multiple presses: Add debounce delay (50ms) and wait for button release
- LEDs do not light up: Check resistor values (220 ohm) and LED polarity (long leg = anode = positive)
- Sequence always the same: Use
randomSeed(analogRead(A0))to seed the random number generator with noise from a floating analog pin
Advanced Features and Extensions
Replace LEDs with WS2812 NeoPixels for RGB colour effects. Add an accelerometer — instead of pressing buttons, tilt the device in the correct direction. This creates a physical, motion-controlled version of Simon Says.
Frequently Asked Questions
What is the maximum level?
With a 100-element array, the game supports 100 levels. Each level adds one step, so level 100 requires memorising and repeating a 100-step sequence. Most humans struggle beyond level 15-20.
Can I use RGB LEDs instead of single-colour LEDs?
Yes, use common-cathode RGB LEDs and assign different colours to each button. You will need 3 pins per LED (12 total) or use a WS2812 strip with just 1 data pin.
Conclusion
The Arduino Simon Says game is a perfect starter project that teaches essential programming concepts while creating something genuinely fun to play. Build it for your college electronics lab, makerspace, or as a gift for younger family members learning electronics.
Add comment