
The classic "repeat the sequence" memory game translates neatly into an Arduino project — four colored LEDs, four matching buttons, and a growing sequence the player has to reproduce exactly.
Components needed
An Arduino, four buttons, four LEDs with current-limiting resistors, a buzzer, and a regulated 5 V source such as USB, a power bank, or a suitable battery pack. A 9 V PP3 battery is generally a poor source for sustained LED and buzzer loads.
How a round plays out
The game opens with a short countdown — five slow LED flashes over about three seconds — before starting. The Arduino then lights one random LED, and the player has two seconds to press the matching button. A correct press adds one more random LED to the sequence, which the player must now repeat from the beginning, one step longer than before.
What ends the game
Pressing the wrong button, or letting the two-second window expire without a press, ends the round: all four LEDs flash rapidly together as a clear "game over" signal, followed by the final sequence being replayed once more so the player can count how many steps they reached before the game resets.
Programming it
Use INPUT_PULLUP with suitable wiring, debounce every button, and present the light sequence without long blocking delays that prevent input scanning. Seed the pseudo-random sequence from a changing source if different startup patterns are required.
You can find LEDs, push buttons, and buzzers at Juthour Tech.
اترك تعليقا