Simon Says Memory Game
In this project, I created a memory game using an Arduino Uno, LEDs, push buttons, and a 7-segment display. The Arduino displays a sequence of LED patterns, and the player must repeat the pattern using the buttons. If the player enters the correct sequence, they advance to the next level. If they make a mistake, the game resets.
Supplies
Idea
I wanted to create a game that would test a player's memory while using the Arduino components we learned about in class.
The goal was to:
- Create an interactive game
- Use LEDs as outputs
- Use buttons as inputs
- Display the current level on a 7-segment display
- Implement multiple levels with increasing difficulty
Research
Research Source 1 – YouTube Video (How the Game Works)
- Watched an Arduino Simon Says game demonstration
- Learned how LED patterns are displayed
- Learned how players repeat patterns using buttons
- Helped me understand the overall game flow and level progression
Research Source 2 – Arduino Simon Says Code
- Studied example code for a similar project
- Learned how arrays can store game sequences
- Learned how loops check user input
- Learned how functions organize code
- Used ideas from the code but wrote my own version
Downloads
Wiring the Circuit
Wiring the LEDs
- Red LED → Pin 12
- Green LED → Pin 10
- Yellow LED → Pin 8
Each LED is connected with an appropriate resistor.
Wiring the Buttons
- Red Button → Pin 13
- Green Button → Pin 11
- Yellow Button → Pin 9
The buttons allow the player to enter the pattern.
Wiring the 7-Segment Display
The 7-segment display is connected to pins 2–7 with pin g connected to A0.
It displays the current level number.
Code
Game Logic Overview
Displaying the LED Pattern
The Arduino displays a sequence of LEDs that the player must memorize. Different functions (case1(), case2(), case3(), etc.) are used to create unique LED patterns for each level.
Storing the Correct Sequence
The correct button sequence for each level is stored in a 2D array called masterPatterns. This allows the program to know which buttons the player should press.
Reading Player Input
The getButtonPress() function waits for the player to press one of the buttons. When a button is pressed, the function returns a value corresponding to that button.
Checking the Answer
A for loop compares each button press to the correct value stored in the array. If the player's input matches the pattern, the game continues. If not, the game ends and resets.
Level Progression
When the player successfully completes a level, the currentLevel variable increases by one. The game becomes more difficult because the patterns become longer and more complex.
7-Segment Display
A 7-segment display shows the player's current level. This gives the player feedback on their progress throughout the game.
Win and Lose Conditions
If the player completes all five levels, all LEDs light up to indicate victory. If the player enters an incorrect sequence, the red LED lights up and the game resets back to Level 1.
Downloads
Final Result
The completed project successfully:
- Displays LED patterns
- Accepts button inputs
- Checks player responses
- Tracks levels using a 7-segment display
- Increases difficulty as the player progresses
This project helped me develop a better understanding of Arduino programming, arrays, functions, loops, and digital electronics.