Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsBuild a defusal game: an LCD counts down from ten while the buzzer beeps, and the player must press the stop button before time runs out. The sketch cannot simply call delay(1000) between ticks, during a delay the ESP32 ignores the button, so a player could press it and nothing would happen. Instead each second is split into ninety short 10 ms waits, and the button is checked between every one of them. A boolean variable remembers whether the player stopped the clock in time. Together, the counter and the flag are the state of the game.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin.
Every part for this build comes in the Geekobot Titan Kit box, a Geekobot exclusive, together with the parts for all 120 projects, from a first blinking LED to a smart fan and a reaction game. The wiring below is the kit's own wiring.
Tick anything you already have and the total updates.
ESP32 DevKit V1 (38-pin): the brain of every Titan Kit project, with Wi-Fi and Bluetooth
Male-to-female and female-to-female leads for the modules
16x2 LCD with I2C backpack: four wires, two lines of text
ESP32 expansion board from the kit: every GPIO has its own S, V, G header
Follow the colours: red is power, dark grey is ground, blue is a signal.
titan_kit_014_countdown_timer_game.inoVerify & upload in Electrolark#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int buzzer = 33;
int button = 25;
int timeLeft = 10;
bool stopped = false;
void setup()
{
lcd.init();
lcd.backlight();
pinMode(buzzer, OUTPUT);
pinMode(button, INPUT_PULLUP);
lcd.setCursor(0, 0);
lcd.print("COUNTDOWN START");
delay(1500);
lcd.clear();
}
void loop()
{
if (stopped)
{
return;
}
if (timeLeft > 0)
{
lcd.setCursor(0, 0);
lcd.print("Time left: ");
lcd.print(timeLeft);
lcd.print(" ");
digitalWrite(buzzer, HIGH);
delay(100);
digitalWrite(buzzer, LOW);
// Wait the rest of the second, watching the button
for (int i = 0; i < 90; i++)
{
if (digitalRead(button) == LOW)
{
stopped = true;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("YOU WIN!");
return;
}
delay(10);
}
timeLeft = timeLeft - 1;
}
else
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("TIME UP!");
digitalWrite(buzzer, HIGH);
delay(2000);
digitalWrite(buzzer, LOW);
while (true)
{
// Game over - press reset to play again
}
}
}
Use a micro-USB data cable (some cables only charge), install the CP210x or CH340 driver if no port appears, pick Tools > Board > ESP32 Dev Module and hold the BOOT button on the board until the upload starts.
The sketch uses INPUT_PULLUP, so one leg goes to the GPIO and the other to GND. Use two legs on opposite sides of the button.
The active buzzer has a + leg: it goes to the GPIO, the other to GND. Peel off the sticker on top if it has one.
Turn the small contrast pot on the back of the I2C board. If still blank, change 0x27 in the sketch to 0x3F.
The sketch cannot simply call delay(1000) between ticks, during a delay the ESP32 ignores the button, so a player could press it and nothing would happen. Instead each second is split into ninety short 10 ms waits, and the button is checked between every one of them. A boolean variable remembers whether the player stopped the clock in time. Together, the counter and the flag are the state of the game.
LCD shows COUNTDOWN START, then Time left: 10, 9, 8 …. The buzzer ticks once every second. Press the button in time and the LCD shows YOU WIN!
Yes. It is project 14 of 120 in the Geekobot Titan Kit, in level 2 (Displays and games). Every part on the list comes in the kit box, and you can also buy the parts one by one from the list above.
No. Every Titan Kit project is wired on the ESP32 expansion board and the breadboard with jumper wires.
8 parts: ESP32-WROOM-32 38-Pin Development Board, USB Cable, Solderless Breadboard, Dupont Jumper Wires (40 pcs), Tactile Push Button Switch, PCB Mounted Active Buzzer Module, LCD1602 16x2 Character LCD Display and ESP32 38-Pin Expansion Board. On this page you can tick the parts you already have and add only the rest to your cart.
It is a beginner project and takes about 30 minutes. The build on this page has 6 steps.
No. This page has the complete, tested code (titan_kit_014_countdown_timer_game.ino).
About ₹832 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Complex timing without blocking the program; State management with flag variables; Splitting a long wait so inputs stay responsive; Printing changing values to an LCD.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin.
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Press to roll: the pips tumble and slow down before landing on a number.
Wait for the light, hit the button: how many milliseconds can you beat?
A bright 4-digit clock that keeps time through power cuts.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.