Arduino Arcade Memory Game

by Dhruv Hegde in Circuits > Arduino

233 Views, 1 Favorites, 0 Comments

Arduino Arcade Memory Game

Untitled (2400 x 2000 px) (2).png
2.png
1709729524861.jpg

Welcome, fellow Autodesk Instructables and Arduino enthusiasts! If you're ready for a thrilling journey into the realm of interactive gaming, you've come to the right place. Today, we'll be delving into the fascinating world of Arduino programming to create a captivating Memory Arcade Game. This game is not just about lights and buttons; it's a dynamic and entertaining experience that challenges your memory skills in a fun, arcade-style setting. In this Instructable, we'll guide you step-by-step through the process of building your own Arduino Memory Arcade Game and how you can assembly and program it to function consistently.

Supplies

1709729524993.jpg
1709729524972.jpg
1709729524979.jpg
  • Arduino Uno
  • Arduino Uno USB-A cable
  • Breadboard
  • 4 LEDs (Red, Green, Blue, White)
  • Jumper Wires (Male: Male)
  • Copper Wire
  • 4 220 Ohm Resistors
  • 4 Buttons
  • Optional: 4 Button Covers

Optional: 3D Printer for the casing

Setting Up LEDs and Resistors

1709729524964.jpg
1709729524956.jpg
1709729524972.jpg
  1. Take your 4 LEDs and organize them sequentially
  2. Place one LED at every 10th slot on the Breadboard
  3. Ensure that the Positive Terminal (+) of the LED is to the right for EVERY LED
  4. Add 220 Ohm resistor one slot below where the Positive LED Terminal is connected
  5. There are no terminals on a resistor, so it does not matter which way you put it

Refer to the diagram above to ensure that your breadboard is laid out correctly.

Adding Resistors and Buttons

1709729524948.jpg
1709729524941.jpg
1709729524933.jpg
  1. Now, we need to add more resistors on the bottom of the breadboard for the buttons that we will be adding
  2. Take 4 more 220 Ohm resistors and place them in the bottom slot of the breadboard in-line with the resistors placed above
  3. Refer to the included diagram to ensure that you have placed the resistors correctly
  4. Take your 4 buttons and connect the metal ends of each of the buttons in the same column/line as the other end of the resistors.
  5. The other buttons are to be connected to nothing else, while one end will be connected to the resistors
  6. If you have colored button covers, place them on the top of the button in the spaces where the LEDs lie. You can mismatch the color or so, but I color mapped based on LED Color.

Voltage Wire and Digital Pins

1709729524926.jpg
1709729524918.jpg

We will need to supply electricity to the LEDs in order to allow them to flash when needed, so we need a voltage wire. Additionally, we must define each of the LED-Button links in our program through digital pins, so we need wires for that as well.

  1. Take 1 Male-Male Jumper wire and plug one end into the 3.3V slot and place the other end in one slot of the positive terminal (labeled + and contains a red line).
  2. Take 4 Male-Male Jumper cables and plug each of them into one of the digital pin slots (for simplicity, I used the digital pins 1, 2, 3 and 4)
  3. Put the other end of the 4 Male-Male Jumper cables in between the right end of the resistor an the left socket of the button, which will make assign the digital pin to that particular slot.

Copper Wiring on Breadboard

1709729524887.jpg
1709729524879.jpg
1709729524871.jpg
  1. Cut 4 short copper wire lengths out, around 2 inches, and plug one end right below the negative (-) left terminal on the LED and the negative terminal (-) on the bottom
  2. Cut out 4 shorter copper wire lengths, around 1 inch, and plug one end in-line with the right side of the button connection and the other end into the positive (+) terminal in the bottom
  3. Cut out 4 shorter copper wire lengths, around 1 inch, and plug one end in-line with the left button slot (with the resistor and digital pin wire) and the other end of the negative terminal on the bottom (+)

This is the most tedious and minute part of assembling this particular device, so make sure you plug the copper wires in precisely and ensure that all that are needed are placed onto the breadboard. Refer to the diagram above

Programming

program two.png
program one.png
  1. Define the wait time between button presses as `PLAYER_WAIT_TIME`.
  2. Declare arrays and variables for the light sequence, input tracking, and pin configurations.
  3. Create functions to set pin directions and write values to all pins to control LEDs.
  4. Implement a flashing function to visually indicate game states (win/lose/reset).
  5. Create a reset function to reset game variables and visually indicate the start of a new game.
  6. Develop a function to handle the game loss scenario, including a rapid flash and sequence display.
  7. Implement a function to display the generated light sequence to the player with appropriate delays.
  8. Set up a loop to handle player input during their turn, checking for correct button presses and timing out if exceeded.
  9. Integrate game logic to compare player input with the generated sequence, handling correct and incorrect inputs accordingly.

3D Print Casing

arcade housing.png
1710078938263.jpg
1710078938255.jpg

Using Fusion 360, design a breadboard casing for your product leaving cutouts for the buttons and for the LEDs to go through.

For the standard 2.2 inch by 7 inch breadboard with the same spacing that I have mentioned for the LEDs and the Buttons, I have included a f3d file below that I designed for this project that you can import into your slicer.

Once you have printed everything, make sure you fold the resistors to not protrude and ensure that the copper wires are not an obstruction. Ensure that everything is still connected as you push the casing on. For my breadboard, this casing was a perfect fit and remained on quite well.

Note: You might have to file the button spaces down a bit if you are using larger button caps as the size I designed takes into account the size of the actual button circuit itself. If you are not using button caps, then you are all set and it should work well. If any issues with fit, you can move the components to see if that solves the issue while ensuring that the components are still connected correctly.

Downloads

Conclusion

Thank you for exploring this Instructable! I hope you found the guide helpful in creating your own memory arcade game using Arduino. Whether you're a novice Arduino enthusiast or a seasoned tinkerer, this project provides an entertaining and educational opportunity to delve into the world of hardware programming. Enjoy building your memory arcade game and have a blast testing your memory! p.s. If you want a challenge, try and beat my personal record of 16 and leave your score in the comments below :)