Arduino Based Five Ten Egg Timer

I love the five-ten egg. It’s a hard-boiled egg that leaves the yolk just a bit soft and the outside done. Simply boil water, drop your egg, and watch your time. At 5 minutes, ten seconds, pull and ice bath the egg to stop cooking. Peel, enjoy.

I have been relearning my Arduino chops, and one of the ways that I’ve done this is by recreating the Arduino starter kit projects, including one for a digital hourglass.

I decided to repurpose the digital hourglass to light an LED each minute through five minutes, then blink the last LED for ten seconds. Here is the circuit:

Arduino Five Ten Egg Timer - John LeMasney

Arduino Five Ten Egg Timer – John LeMasney

Here is the code:

Arduino Starter Kit example
Project 8 – Digital Hourglass, modified to a Five-Ten egg timer.

This sketch is written to accompany Project 8 in the
Arduino Starter Kit

Parts required:
10 kilohm resistor
six 220 ohm resistors
six LEDs
tilt switch

Created 13 September 2012
by Scott Fitzgerald

Modified 13 August 2014
by John LeMasney

This example code is part of the public domain

// named constant for the switch pin
const int switchPin = 8;

unsigned long previousTime = 0; // store the last time an LED was updated
int switchState = 0; // the current switch state
int prevSwitchState = 0; // the previous switch state
int led = 2; // a variable to refer to the LEDs

// 60000 = 1 minutes in milliseconds
long interval = 60000; // interval at which to light the next LED

void setup() {
// set all of the LED pins as outputs
for(int x = 2;x<8;x++){
pinMode(x, OUTPUT);
// set the tilt switch pin as input
pinMode(switchPin, INPUT);

void loop(){
// store the time since the Arduino started running in a variable
unsigned long currentTime = millis();

// compare the current time to the previous time an LED turned on
// if it is greater than your interval, run the if statement
if(currentTime – previousTime > interval) {
// save the current time as the last time you changed an LED
previousTime = currentTime;
// Turn the LED on
digitalWrite(led, HIGH);
// increment the led variable
// in 1 minute the next LED will light up

if(led == 6){
// the 5 minutes is up, light up fifth LED, then blink last LED for ten seconds, then leave solid.
for(int b = 1;b<6;b++){

// read the switch value
switchState = digitalRead(switchPin);

// if the switch has changed
if(switchState != prevSwitchState){
// turn all the LEDs low
for(int x = 2;x<8;x++){
digitalWrite(x, LOW);

// reset the LED variable to the first one
led = 2;

//reset the timer
previousTime = currentTime;
// set the previous switch state to the current state
prevSwitchState = switchState;

This content is published under the Attribution 3.0 Unported license.

Leave a Reply