Memory Game

For this project, I created an Arduino Memory Game that challenges players to remember and repeat a growing sequence of lights. The goal is to successfully follow the pattern through 10 levels to win.
You play the game by pressing buttons in the correct sequence. If you press the wrong button or simply take too long to respond, you lose and the game ends. I also included a RGB LED to the game to make it easy to follow and a 7 Segment Display to track your score and show levels played.
I chose to base my game off a similar Arduino memory game projects I found on Instructables. A few things I had to research was how to randomize the order of the lights after each round, how to sync up the 7 Segment Display to the score system, etc. From my research I had learned to use a few new things, such as arrays, that helped make the process and program much easier to built and understand.
I began by building my Arduino before I made the code, and had to make many improvements on it throughout the process such as figuring out the right strength of resisters I needed and to not put the power and ground on the same terminal on the button. I had also made many debugging and improvements on the overall code such as ensuring to add delays where it needed it and adding the waiting sequence that plays when the game wasn't active.
Overall, I learned a lot from this project and was able to apply much of what I learned in class to the project. I had a lot of fun making this game, and I hope you do too!
Supplies

- Arduino x 1
- Breadboard x 1
- Push Buttons x 3
- LEDs x 3 (Red, Green, Yellow)
- RGB LED x 1(Common Cathode)
- 330Ω Resistors x 6
- 10kΩ Resistors x 3
- 7 Segment display x 1(Common Anode)
- Wires (as required)
Components

Place the push buttons onto the breadboard bridged over the central gap. Connect one leg of each button to the GND rail using a 10kΩ resistor. Connect the other leg of each button to the power rail.
Place the LEDs onto the breadboard next to a corresponding button. Connect the negative legs of each LED to GND rail using a 330Ω resistor. Also place the RGB LED onto the breadboard and connect its cathode (longest) leg to Power rail using a 330Ω resistor.
Place the 7 segment display onto the breadboard bridged over the central gap. Connect both common (middle pins) to the Power rail using 330Ω resistors.
Connections



Connect (Image 1)
- the green button leg, connected to the resistor, to Pin 13
- the yellow button leg to Pin 11
- the red button leg to Pin 9
Connect (Image 2)
- the green LED's positive (longer) leg to Pin 12
- the yellow LED's positive (longer) leg to Pin 10
- the red LED's positive (longer) leg to Pin 8
Connect (Image 3)
- the green leg (outermost) to Pin ~6
- the blue leg (middle / next to cathode) to Pin ~5 and
- the red leg (other side of cathode) to Pin ~3
*RGB LED works best with PWM (~) Pins
Connections Cont.


Connect (Image 1)
- 'C' (4th leg on bottom) to Pin 2,
- 'D' (2th leg on bottom) to Pin A5
- 'E' (1th leg on bottom) to Pin A4
- 'G' (1th leg on top) to Pin A3
- 'F' (2th leg on top) to Pin A2
- 'A' (4th leg on top) to Pin A1
- 'B' (5th leg on top) to Pin A0
Finally, connect the GND rail to GND Pin and the Power rail to 5V Pin. Also connect the other side of the breadboard with wires to allow power and GND there as well. (Image 2)
*Reminder - All of these components (buttons, LEDs, RGB LED, 7-segment display, etc.) can be connected to any of the Arduino pins, Just make sure to update the pin numbers in your code to match your wiring.
Code
This is the code I used for my project. Feel free to customize the code to fit your set up and / or requirement, or even write your own version entirely to make the code your own.
Downloads
Tinkercad Version

Schematic View
