Project Name: Game Minda (Memory Game)
Category: Gaming, Hardware Control, LED/Sound Effects
Difficulty: Intermediate
This project transforms your Myduino AIoT Education Kit into a standalone memory game, similar to the classic Simon game. Players must observe a sequence of lights and sounds and repeat it correctly. The sequence grows with each successful attempt, and a NeoPixel strip acts as a visual “streak” bar.
Learning Objectives (What You Will Learn)
By building this project, you will learn to:
- Make a Screen Work: Use a small LCD screen (I2C) to show the game level and score.
- Control Lights: Turn four simple LEDs on and off to show the memory sequence.
- Control Buttons: Read the four press-buttons to know which color the player chose.
- Make Sounds: Use a buzzer to play the different tones for the sequence.
- Make a Light Show: Use a cool, multi-color NeoPixel strip to show how many levels you’ve passed (your “streak”).
Circuit Connections

| Components | ESP32 Dev Module | Function |
| LCD I2C SDA | IO21 | How the screen sends data to the ESP32 (Part of the communication pair) |
| LCD I2C SCL | IO22 | The timing signal for the screen (Part of the communication pair) |
| RED LED | IO14 | Flashes to show the Red part of the memory sequence |
| YELLOW LED | IO27 | Flashes to show the Yellow part of the memory sequence |
| GREEN LED | IO26 | Flashes to show the Green part of the memory sequence |
| BLUE LED | IO25 | Flashes to show the Blue part of the memory sequence |
| RED BUTTON | IO15 | Press this to repeat the Red part of the sequence |
| YELLOW BUTTON | IO2 | Press this to repeat the Yellow part of the sequence |
| GREEN BUTTON | IO4 | Press this to repeat the Green part of the sequence |
| BLUE BUTTON | IO5 | Press this to repeat the Blue part of the sequence |
| BUZZER | IO13 | Makes the sounds for the sequence tones, countdown, and Game Over alarm |
| WS2812 (RGB LED) | IO12 | The multi-color “Streak Bar” that lights up as you pass more levels |
Code Lab

Step 1: Install Libraries
Before upload the code, you need to install these libraries in Library Manager Arduino IDE:
- LiquidCrystal_I2C.h by Frank de Brabander (for LCD)
- Adafruit_Neopixel.h by Adafruit (for WS2812)
- Wire.h (already built-in in ESP32)
Step 2: Code
Copy and paste this code into Arduino IDE
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_NeoPixel.h>
// ===== LCD Setup =====
LiquidCrystal_I2C lcd(0x27, 16, 2);
// ===== Pins =====
int leds[] = {14, 27, 26, 25}; // LEDs: Red, Yellow, Green, Blue
int buttons[] = {15, 2, 4, 5}; // Push buttons
int tones[] = {262, 294, 330, 349}; // Sound for each button
int buzzer = 13;
// ===== NeoPixel Setup =====
#define NEOPIXEL_PIN 12
#define NUMPIXELS 6
Adafruit_NeoPixel pixels(NUMPIXELS, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);
// ===== Game Variables =====
int sequence[100];
int level = 1;
void setup() {
// Initialize LCD
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Memory Game");
// Initialize IO
for (int i = 0; i < 4; i++) {
pinMode(leds[i], OUTPUT);
pinMode(buttons[i], INPUT_PULLUP);
}
pinMode(buzzer, OUTPUT);
// Initialize NeoPixel
pixels.begin();
pixels.show();
// Seed randomness
randomSeed(analogRead(0));
delay(2000);
lcd.clear();
}
void loop() {
waitForStart(); // Wait for button press before starting
level = 1;
while (true) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Level: ");
lcd.print(level);
delay(1000);
// Add new step
sequence[level - 1] = random(0, 4);
// Show sequence
for (int i = 0; i < level; i++) {
int idx = sequence[i];
digitalWrite(leds[idx], HIGH);
tone(buzzer, tones[idx], 300);
delay(400);
digitalWrite(leds[idx], LOW);
delay(200);
}
// User input
for (int i = 0; i < level; i++) {
bool correct = false;
unsigned long start = millis();
while (millis() - start < 3000) {
for (int j = 0; j < 4; j++) {
if (digitalRead(buttons[j]) == LOW) {
digitalWrite(leds[j], HIGH);
tone(buzzer, tones[j], 200);
delay(300);
digitalWrite(leds[j], LOW);
while (digitalRead(buttons[j]) == LOW); // Wait for release
if (j == sequence[i]) {
correct = true;
}
goto check;
}
}
}
check:
if (!correct) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Wrong!");
lcd.setCursor(0, 1);
lcd.print("Score: ");
lcd.print(level - 1);
tone(buzzer, 100, 500);
delay(3000);
pixels.clear();
pixels.show();
return; // Restart
}
}
updateStreakBar(level); // Update RGB bar
level++;
delay(1000);
}
}
void waitForStart() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Memory Game");
lcd.setCursor(0, 1);
lcd.print("Press Any Button");
while (true) {
for (int i = 0; i < 4; i++) {
if (digitalRead(buttons[i]) == LOW) {
while (digitalRead(buttons[i]) == LOW); // Wait release
countdown();
return;
}
}
delay(10);
}
}
void countdown() {
for (int i = 3; i >= 1; i--) {
lcd.clear();
lcd.setCursor(5, 0);
lcd.print("Ready");
lcd.setCursor(7, 1);
lcd.print(i);
tone(buzzer, 1000, 200);
delay(1000);
}
lcd.clear();
lcd.print("GO!");
tone(buzzer, 1500, 300);
delay(1000);
lcd.clear();
}
void updateStreakBar(int level) {
int streak = (level + 1) / 2;
for (int i = 0; i < NUMPIXELS; i++) {
if (i < streak) {
// Random color for each success
uint8_t r, g, b;
hsvToRgb(i * (255 / NUMPIXELS), 255, 60, r, g, b); // 60 = dim brightness
pixels.setPixelColor(i, pixels.Color(r, g, b));
} else {
pixels.setPixelColor(i, 0); // Off
}
}
pixels.show();
}
// Converts HSV values (0-255) to RGB (0-255)
void hsvToRgb(uint8_t h, uint8_t s, uint8_t v, uint8_t &r, uint8_t &g, uint8_t &b) {
uint8_t region, remainder, p, q, t;
if (s == 0) {
r = g = b = v;
return;
}
region = h / 43;
remainder = (h - (region * 43)) * 6;
p = (v * (255 - s)) >> 8;
q = (v * (255 - ((s * remainder) >> 8))) >> 8;
t = (v * (255 - ((s * (255 - remainder)) >> 8))) >> 8;
switch (region) {
case 0: r = v; g = t; b = p; break;
case 1: r = q; g = v; b = p; break;
case 2: r = p; g = v; b = t; break;
case 3: r = p; g = q; b = v; break;
case 4: r = t; g = p; b = v; break;
default: r = v; g = p; b = q; break;
}
}
Step 3: Upload and Run
- Select the correct board (ESP32 Dev Module) and Port.
- Click Upload
How to Play Game Minda

This game is all about testing your memory by having you repeat a sequence of lights and sounds.
Step 1: Start the Game
- Turn it On: Plug in your scoreboard. The small screen (LCD) will say:
Memory Game. - Ready to Go: The screen will then say:
Press Any Button. - Start: Press any one of the four color buttons.
- The game will count down from 3 to 1 and then shout “GO!”
Step 2: Watch and Listen to the Sequence
- Level Up: The screen shows your current
Level. - Watch Closely: The game plays a sequence of lights and sounds. This is the SECRET PATTERN you must remember!
- Repeat Perfectly: Press the buttons in the EXACT SAME ORDER you just saw.
- Tip: You get a little light sound every time you press a correct button!
- Be Fast! You have a short 3-second time limit for each button press. Don’t hesitate!
Step 3: Victory and Defeat
| If you… | Result | What Happens? |
| Win the Round | EPIC WIN! | Your Streak Bar (NeoPixels) lights up a new color, and the pattern gets even longer! |
| Press the Wrong Button | DEFEAT! | The buzzer sounds a fail alarm! The screen shows “Wrong!” and your final Score. |
| Are Too Slow | DEFEAT! | Same as above! You must be quick! Export to Sheets |
To restart the mission, just press any button after the Game Over screen!
Troubleshooting Guide (What to Do If It Doesn’t Work)
| Problem | What is Happening? | Simple Solution to Try |
| The screen is dark or shows black boxes. | The LCD isn’t communicating or the brightness/contrast is wrong. | 1. Check Wires: Make sure SDA (21) and SCL (22) are tightly connected. 2. Adjust Knob: Turn the small blue/white screw (potentiometer) on the top of the LCD module. |
| I press a button, but nothing happens. | The ESP32 isn’t detecting the button press. | Check Wiring: Make sure one side of the button goes to the correct GPIO pin (15, 2, 4, or 5) |
| The four simple colored LEDs (Red/Yellow/etc.) don’t light up. | The LEDs are wired backward | Check Polarity: The GPIO pin connections of the LED must go to the GPIO pin (14, 27, 26, 25) |
| The buzzer doesn’t make any sounds. | The buzzer pin is not connected correctly. | Check Wiring: Make sure the buzzer is correctly wired to GPIO13 |
| The multi-color “Streak Bar” (NeoPixels) is dark. | The strip might not be getting power or data. | Check Data: Double-check that the GPIO pin is connected to GPIO12 |
| The sequence is the same every time I play. | The game’s “randomness” is using the same starting number. | In the code, you can try changing analogRead(0) to analogRead(39) or another valid ADC pin to find a better random starter value. |
Tips: If you want to find any lines in Arduino IDE, click CTRL+F (CMD + F on Mac) and search the line you want to find (applicable to any platform).
Buy from:
Myduino AIoT Education Kit from myduino.com






