Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsA potentiometer module gives the ESP32 an analog voltage that follows the knob. The sketch maps it to 1 to 60 minutes, shows the time on an OLED, and uses one of the ESP32's built-in touch pins as a start button, so no push button is needed. When the countdown ends the buzzer beeps until you touch the pad again. It is handy for study sessions (Pomodoro) and cooking, and the OLED draws a bar that shrinks as time runs out.
Tick anything you already have and the total updates.
Rotary potentiometer module
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB power bank for a portable timer.
countdown.inoVerify & upload in Electrolark#include <Wire.h>
#include <Adafruit_SSD1306.h>
const int POT = 34, BUZZ = 25, TOUCH = 4, THRESHOLD = 30;
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
enum State { SETTING, RUNNING, RINGING } state = SETTING;
unsigned long endAt = 0, totalMs = 0;
bool wasTouched = false;
void setup() {
pinMode(BUZZ, OUTPUT);
Wire.begin(21, 22);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
oled.setTextColor(WHITE);
}
void loop() {
bool touched = touchRead(TOUCH) < THRESHOLD;
bool pressed = touched && !wasTouched;
wasTouched = touched;
oled.clearDisplay();
if (state == SETTING) {
int minutes = map(analogRead(POT), 0, 4095, 1, 60);
oled.setTextSize(3); oled.setCursor(10, 10); oled.printf("%02d:00", minutes);
oled.setTextSize(1); oled.setCursor(0, 50); oled.print("touch pad to start");
if (pressed) { totalMs = minutes * 60000UL; endAt = millis() + totalMs; state = RUNNING; }
} else if (state == RUNNING) {
long left = (long)(endAt - millis());
if (left <= 0) { state = RINGING; }
else {
oled.setTextSize(3); oled.setCursor(10, 10); oled.printf("%02ld:%02ld", left / 60000, (left / 1000) % 60);
int w = (int)(120L * left / (long)totalMs);
oled.drawRect(2, 44, 124, 12, WHITE); oled.fillRect(4, 46, w, 8, WHITE);
if (pressed) state = SETTING; // touch again to cancel
}
} else {
oled.setTextSize(2); oled.setCursor(10, 20); oled.print("TIME UP");
digitalWrite(BUZZ, (millis() / 300) % 2 ? HIGH : LOW);
if (pressed) { digitalWrite(BUZZ, LOW); state = SETTING; }
}
oled.display();
delay(30);
}
The ESP32 ADC is noisy; average a few readings, or use a 100 nF capacitor on the signal.
Lower THRESHOLD, or shorten the wire. Print touchRead to find a good value.
Check SDA and SCL and try address 0x3D.
Yes, wire a button to a pin and use INPUT_PULLUP.
60 minutes as written; change the map range for longer.
Yes. It uses the ESP32's own timer, so it does not need Wi-Fi.
6 parts: ESP32-WROOM-32 38-Pin Development Board, HS-S28P Rotary Potentiometer Module – Analog Angle Sensor w/ PH2.0 Connector, 0.96" OLED Display 128x64, Buzzer Module 3.3–5V, Solderless Breadboard and Dupont Jumper Wires (40 pcs). 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 1 hour. The build on this page has 6 steps.
No. This page has the complete, tested code (countdown.ino).
About ₹731 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Reading a potentiometer with the ESP32 ADC; Counting down with millis() without blocking; Using a touch pin as a start button.
Ideas that reuse this build: ESP32 alarm clock with NTP. They are listed under Take it further on this page.
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.