Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsBuild a beat-the-clock 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 Arduino 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.
Every part for this build comes in the Geekobot Explorer Kit box, a Geekobot exclusive, together with the parts for all 61 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.
The brain of every Explorer Kit project
Male-to-female and female-to-female leads for the modules
16x2 LCD with I2C backpack: four wires, two lines of text
Nano I/O shield from the kit: every pin has its own S, V, G header, so modules plug in with jumpers
Follow the colours: red is power, dark grey is ground, blue is a signal.
explorer_kit_14_countdown_game.inoVerify & upload in Electrolark#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int buzzer = 8;
int button = 7;
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 the kit's mini-USB cable, install the CH340 driver on Windows if no port appears, pick Tools > Board > Arduino Nano and try Tools > Processor > ATmega328P (Old Bootloader) if the upload times out.
The sketch uses INPUT_PULLUP, so one leg goes to the pin and the other to GND. Use two legs on opposite sides of the button.
The active buzzer has a + leg: it goes to the pin, 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 Arduino 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 61 in the Geekobot Explorer 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 Explorer Kit project is wired on the Nano I/O shield and the breadboard with jumper wires.
7 parts: Generic Nano CH340 Development Board (Soldered), USB Cable, Dupont Jumper Wires (40 pcs), Tactile Push Button Switch, PCB Mounted Active Buzzer Module, LCD1602 16x2 Character LCD Display and Arduino Nano IO Expansion Shield (328P Compatible). 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 45 minutes. The build on this page has 6 steps.
No. This page has the complete, tested code (explorer_kit_14_countdown_game.ino).
About ₹565 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.
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.
Learning project. Check every circuit and the datasheet of each part before you power it up.