Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsThe common Uno multifunction shield packs a 4-digit 7-segment display (driven by two 74HC595 shift registers), three buttons, four LEDs, a buzzer and a potentiometer on one board with no wiring at all. The display is multiplexed: the Uno lights one digit at a time very fast, so your eye sees all four. This timer uses the three buttons to add a minute, add ten seconds and start or stop.
Tick anything you already have and the total updates.
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB or a 9 V adapter on the Uno.
timer.inoVerify & upload in Electrolarkconst int LATCH = 4, CLK = 7, DATA = 8, BUZ = 3;
const byte SEG[] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90}; // common anode, 0-9
const byte DIG[] = {0xF1, 0xF2, 0xF4, 0xF8};
int secs = 0; bool running = false, ringing = false;
unsigned long lastTick = 0;
void show(byte pos, byte seg) {
digitalWrite(LATCH, LOW);
shiftOut(DATA, CLK, MSBFIRST, seg);
shiftOut(DATA, CLK, MSBFIRST, DIG[pos]);
digitalWrite(LATCH, HIGH);
}
bool pressed(int pin) {
static unsigned long last[4];
int i = pin - A1;
if (digitalRead(pin) == LOW && millis() - last[i] > 250) { last[i] = millis(); return true; }
return false;
}
void setup() {
pinMode(LATCH, OUTPUT); pinMode(CLK, OUTPUT); pinMode(DATA, OUTPUT);
pinMode(BUZ, OUTPUT); digitalWrite(BUZ, HIGH);
for (int p = 10; p <= 13; p++) { pinMode(p, OUTPUT); digitalWrite(p, HIGH); }
}
void loop() {
bool any = false;
if (pressed(A1)) { secs = min(secs + 60, 5999); any = true; }
if (pressed(A2)) { secs = min(secs + 10, 5999); any = true; }
if (pressed(A3)) { running = !running && secs > 0; any = true; }
if (ringing && any) { ringing = false; digitalWrite(BUZ, HIGH); }
if (running && millis() - lastTick >= 1000) {
lastTick = millis();
if (--secs <= 0) { secs = 0; running = false; ringing = true; }
}
if (ringing) digitalWrite(BUZ, (millis() / 300) % 2);
for (int p = 10; p <= 13; p++) digitalWrite(p, !(running && secs < 60));
int m = secs / 60, s = secs % 60;
byte d[4] = {SEG[m / 10], (byte)(SEG[m % 10] & 0x7F), SEG[s / 10], SEG[s % 10]}; // dot after minutes
for (int i = 0; i < 4; i++) { show(i, d[i]); delay(2); }
}
Something in loop() is slow; keep delays out of the loop except the 2 ms per digit.
Your shield's buzzer is active HIGH; swap HIGH and LOW for BUZ.
Some shields are common cathode; invert the SEG bytes with ~.
Yes, it is on A0; you could use it to set the minutes instead of a button.
Yes, the pins are the same.
Yes, add one to secs instead of taking one away.
2 parts: Uno R3 CH340G ATmega328p Compatible Development Board and Arduino Uno Leonardo Multifunction Shield. 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 5 steps.
No. This page has the complete, tested code (timer.ino).
About ₹327 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Driving 7-segment digits through shift registers; Multiplexing a display; Debouncing buttons.
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.