Simon Says Memory Game
This Arduino Simon says memory game is a fun electronic memory game made with 5 LEDs, 5 push buttons and piezo buzzer. The game works by showing a random pattern using lights and sounds, then the player just repeats the same pattern by pressing the correct buttons in the correct order. Each LED has one matching push button so the layout is simple to understand and play. The game also includes starting animations where the LEDs move forward and backward until any button is pressed. If the player repeats the sequence correctly the game will move on to the next level and adds one more random step to the pattern. If the wrong button is pressed, all the Les flash and the buzzer plays a low sound to show that the game is over. If the player reaches the final level, the victory mode turns on the LED and plays a high buzzer sound.
Supplies
- 1 Arduino Uno
- 1 solderless breadboard
- 5 LEDs
- 5 mini push button switches
- 1 piezo buzzer
- 5 LED resistors
- 5 10k ohm resistors for the push buttons
- Jumper wires
- 1 USB cable
- Computer or laptop
- Arduino IDE software
Placing All the Components
Before wiring the circuit the full should be planned. Start by placing 5 LEDs and push buttons onto the breadboard in an organized layout. Each should correspond to 1 push button so the player can easily identify which button marches each light during the game. The components should be spaced evenly to reduce writing conviction and make trouble shooting later in the project. Planning the layout before connecting it helps make it easier to understand when presenting it. Keeping the LEDs and buttons aligned also improves the overall appearance of the project and allows the player to quickly understand the pattern during the games. Talking time to organize the components will help prevent wiring mistakes later in the building process.
Wiring the LEDs
Connect the 5 LEDs to digital pins 2,4,6,8 and 10. Each LED should be connected through a 330K Resistor to limit the current flowing through the LED and save it from any damages. LEDs are polarized components meaning they must be installed in the correct direction for current to flow properly. During playing it, these LEDs display a random sequence generated by the arduino and provide visual feedback whenever a player presses a button. Proper LED writing is important because the lights are the primary way players observe and memorize the pattern, if an LED does not light up during testing check the LED placement many times the LED is placed upside down, resistor placement and wire connection should all be checked carefully.
Wiring the Push Buttons
Connect the 5 push buttons to arduino digital pins 3,5,7,9 and 11 using 10k resistors pull down resistor. These resistors prevent floating inputs, which happen when an arduino input pin randomly changes between high and low because it is not connected to a stable voltage. When a button is not pressed, the resistor keeps the pin reading low and when the button is pressed the pin reads high. THis creates reliable input signals and ensures the game accurately detects players responses without a false button presser. The push buttons are one of the most crucial parts of this project because they allow the player to interact with the game and repeat the sequence shown by the arduino.
Connecting the Piezo Buzzer
Connect the positive terminal of the piezo buzzer to arduino pin 12 and connect the negative terminal to ground. The buzzer generates different tones throughout the game and helps provide audio feedback for the players. Each LED in the sequence is paired with a unique sound, it allows the player to use both visual and audio cues when remembering the pattern. The buzzer also produces special sounds during successful rounds, game over events and winning mode, making the game more engaging. Audio improves it because it provides an additional way for players to remember the sequences.
How the Game Works
When powered on, the game starts with a starting animation where the LEDs move forward and backward repeatedly until a button is pressed. THis feature lets the player know the game is ready to start, once the arduino generated pattern is started and displays it using the LEDs and buzzer. The player must then repeat the pattern by pressing the matching buttons in the same order. If every button is correct, the level increases and another random step is added to the sequences . As levels increase the pattern becomes longer and harder, requiring grader memory skills. If a wrong button is pressed at any point, the game is over and the sequence is activated, all the LEDs flash and the game resets back to level 1.
Testing the Circuit:
Testing should be executed after uploading the code to make sure all the components functions correctly. Each button should activate its matching LED and sounds, the sequence should display properly and the buzzer should play different tones for different LEDs. Testing should also include internationally making mistakes to verify that the game is over sequence functions correctly. Testing also confirms that all inputs, outputs, wiring connection and programming logic are operating as expected before showing. Multiple rounds should be played to make sure that level system works correctly and continues adding new steps to the sequence. Any writing problems discovered during testing should be corrected before moving on to the final stage. Best Recommended You can also tell your friend to test or play it and ask their experience on it.
int leds[5] = {2,4,6,8,10};
int buttons[5] = {3,5,7,9,11};
int buzzer = 12;
int level = 1;
int sequence[20];
void setup() {
Serial.begin(9600);
for (int i = 0; i < 5; i++){
pinMode(buttons[i],INPUT);
}
for (int i = 0; i < 5; i++){
pinMode(leds[i],OUTPUT);
}
pinMode(buzzer,OUTPUT);
randomSeed(analogRead(A0));
gameStart();
sequence[0] = random(0,5);
}
void loop() {
//show sequence
showSequence();
bool player_correct = true;
for (int i = 0; i < level; i++){
int btn_pressed = buttonPlayerPressed();
if (btn_pressed != sequence[i]){
player_correct = false;
break;
}
}
if (player_correct == true){
tone(buzzer,1000,200);
delay(300);
level++;
if (level > 10){
victoryMode();
level = 1;
sequence[0] = random(0,5);
delay(1000);
}
sequence[level - 1] = random(0,5);
delay(1000);
}
else {
gameOver();
level = 1;
sequence[0] = random(0,5);
gameStart();
return;
}
//wait for player to play
//check if player is correct or not
//assume player is correct
//check all the buttons are pressed or not
//if yes next pattern
//if no then game over
}
void showSequence(){
delay(500);
for (int i = 0; i < level; i++){
int led_count = sequence[i];
digitalWrite(leds[led_count],HIGH);
tone(buzzer, 500 + led_count * 150);
delay(500);
digitalWrite(leds[led_count],LOW);
noTone(buzzer);
delay(250);
}
}
int buttonPlayerPressed(){
while (true){
for (int i = 0; i < 5; i++){
if (digitalRead(buttons[i]) == HIGH){
digitalWrite(leds[i],HIGH);
tone(buzzer, 500 + i * 150);
delay(100);
while (digitalRead(buttons[i]) == HIGH){
delay(10);
}
digitalWrite(leds[i],LOW);
noTone(buzzer);
delay(100);
return i;
}
}
}
}
void gameOver(){
noTone(buzzer);
for (int i = 0; i < 2; i++){
for (int i = 0; i < 5; i++){
digitalWrite(leds[i], HIGH);
}
tone(buzzer, 200);
delay(300);
noTone(buzzer);
for (int i = 0; i < 5; i++){
digitalWrite(leds[i], LOW);
}
delay(500);
}
}
void gameStart(){
bool startGame = false;
while (!startGame){
// forward
for (int i = 0; i < 5; i++){
digitalWrite(leds[i],HIGH);
delay(150);
digitalWrite(leds[i],LOW);
if (checkButtonPressed()){
startGame = true;
break;
}
}
//backward
for (int i = 3; i > 0; i--){
digitalWrite(leds[i],HIGH);
delay(150);
for (int j = 0; j < 15; j++){
if (checkButtonPressed()){
startGame = true;
break;
}
}
digitalWrite(leds[i],LOW);
}
}
delay(500);
}
bool checkButtonPressed(){
for (int i = 0; i < 5; i++) {
if (digitalRead(buttons[i]) == HIGH) {
delay(50); // debounce
if (digitalRead(buttons[i]) == HIGH) {
while (digitalRead(buttons[i]) == HIGH) {
delay(10);
}
return true;
}
}
}
return false;
}
void victoryMode(){
for(int i = 0; i < 5; i++){
digitalWrite(leds[i],HIGH);
}
tone(buzzer, 2000);
delay(3000);
noTone(buzzer);
for(int i = 0; i < 5; i++){
digitalWrite(leds[i],HIGH);
}
}
Testing the Circuit
Once testing is completed, organize the jumper wired to improve the appearance and readability of the circuit. The completed game features a staring animation, random sequence generation, increasing difficulty levels, audio and visual feedback. These features work together to create a complete interactive memory game that challenges players while remaining fun to use. Organising the writes and making sure all the components are secure also helps improve the presentation.