Memory Game

by 772911 in Circuits > Arduino

87 Views, 1 Favorites, 0 Comments

Memory Game

p16986316_v_h9_aa.jpg

Today, we will be building a memory game to test your memory skills.

In this version of the memory game, four different LEDs (green, red, blue, and yellow) will randomly blink in a pattern that you must memorize. You will then input the pattern using buttons.

The RGB LED will turn blue when the game begins. If you make any errors or mistakes during the game, the RGB LED will turn red, indicating that you have failed the game and it will automatically restart. During this phase, the piezo buzzer will be playing in the background. It will buzz to indicate that the game has begun and will buzz again if you lose.

For each round, the 7-segment display will show the user the current round, starting from 1 and going up to 5.

Supplies

20240613_120752 (1).jpg

For this project you will need the components listed below:

  • Bread Board
  • Arduino
  • RDG LED ( Common Anode or CA)
  • 4x LED (Green, Blue, Red, Yellow)
  • Piezo buzzer
  • 7 Segment Display ( Common Anode or CA)
  • 4 Buttons (Used for LED)
  • 4x 10k resistors (used for the buttons)
  • 4x 330 ohm resistors (used for the LEDs)
  • 3x 560ohm resistors (used for the RGB LED and 7 Segment Display)

Wiring

20240613_124156.jpg
1718760158820.jpg

This is a key part, so make sure you do your wiring accurately.

  • The button should be connected to the positive power line, with a 10K ohm resistor on the ground line.
  • The LEDs should have their negative pins connected to the ground line and their positive pins connected to 330-ohm resistors.
  • The RGB LED should be connected to power with a 560 ohm resistor on the positive line, as it is a common anode. Connect the positive power to the green pin, since we don't need it for this project.
  • The buzzer should have its negative pin connected to the ground.
  • The 7-segment display should have been given positive power through two 560-ohm resistors to the common pins.

The rest of the empty pins should be directly connected to the Arduino pins as shown in the second picture.

Uploading the Code

After completing all the wiring from Step 1, go to the Arduino Software and upload the provided code. If you have made any changes to the wiring, make sure to update the pin numbers in the code accordingly.

The code enables the circuit's functions. Pressing any button starts the game, causing the LEDs to blink in random patterns. Players must press the 4 buttons in the correct order until they reach stage 5, as shown on the 7-segment display. If a mistake is made, the RGB LED lights up red, indicating failure. Pressing any button again will light up the RGB LED blue, signaling the game can restart.

The game involves visual aspects:

  • Sequence Playback: LEDs light up and a musical note plays for each step in the sequence.
  • User Input: Players repeat the sequence, with LEDs lighting up and musical notes playing for each button press.
  • RGB LED indicates outcomes:
  • Blue: Correct sequence completed, victory song plays.
  • Red: Wrong answer or timeout, loss song plays, game restarts.
  • Blue: Ready to restart the game.

The game consists of 5 rounds to win, displayed on the 7-segment display. Background music plays through the buzzer to enhance the gameplay experience.







Downloads