กลับไปหน้ารวมไฟล์
compact-memory-game-en.md

Test Your Memory!

The Compact Memory Game is a DIY version of the legendary Simon game. It challenges players to remember and replicate increasingly long sequences of light and sound. It's an excellent project for beginners to learn about input handling, array management, and audio-visual feedback in Arduino.

arduino_memory_game_topview_1772681131358.png

The Rules of the Game

  1. The Sequence: The game starts by flashing one of the four colored LEDs randomly.
  2. The Turn: The player must press the button corresponding to that LED.
  3. The Expansion: If correct, the game plays the same sequence again but adds one new random step to the end.
  4. Game Over: If the player presses the wrong button, a "sad" tone plays, and the score is reset.

Hardware Components

This project is designed to be extremely portable, fitting easily on a mini breadboard.

  • Arduino Nano: The compact brain of the operation.
  • 4 Colored LEDs: Red, Blue, Green, and Yellow to represent the four notes.
  • 4 Push Buttons: Tactile inputs for the player.
  • Piezo Buzzer: Provides a unique tone for each color, helping the player memorize through sound.
  • Resistors: 220-ohm for LEDs and 10k-ohm pull-down for buttons.

arduino_memory_game_piezo_macro_1772681197420.png

Code Highlights

The primary challenge in the code is managing the gameSequence[] array. The Arduino must keep track of the sequence generated so far and compare each button press from the user against the expected value at that position.

Using the tone() function, we assign a specific frequency to each LED:

  • Red: 261Hz (Middle C)
  • Blue: 329Hz (E)
  • Green: 392Hz (G)
  • Yellow: 523Hz (High C)

This creates a melodic experience that makes the game feel responsive and polished.

ข้อมูล Frontmatter ดั้งเดิม

title: "Compact Memory Game for Arduino Nano"
description: "Test your memory with this classic 'Simon Says' style sequence game. Built with an Arduino Nano, 4 LEDs, and a piezoelectric buzzer for a compact, fun experience."
category: "Games & Toys"
difficulty: "Easy"