if (digitalRead (secondPin)==LOW && secPressed == false) { // if a normally closed switch is pressed
second++; // advance by one second
secPressed = true; // note the pressed state
}
if (digitalRead (secondPin)==HIGH) secPressed = false; // reset the state when the button is released

void serialOutput() {
// this function creates a clock you can read through the serial port
// your clock project will have a MUCH more interesting way of displaying the time
// get creative!
printWeekday(weekday); // picks the right word to print for the weekday
Serial.print(", "); // a comma after the weekday
Serial.print(hour, DEC); // the hour, sent to the screen in decimal format
Serial.print(":"); // a colon between the hour and the minute
Serial.print(minute, DEC); // the minute, sent to the screen in decimal format
Serial.print(":"); // a colon between the minute and the second
Serial.println(second, DEC); // the second, sent to the screen in decimal format
}

// this utility function blinks the an LED light as many times as requested
void blinkLED(byte targetPin, int numBlinks, int blinkRate) {
for (int i=0; i < numBlinks; i++) {
digitalWrite(targetPin, HIGH); // sets the LED on
delay(blinkRate); // waits for a blinkRate milliseconds
digitalWrite(targetPin, LOW); // sets the LED off
delay(blinkRate);
}
}

15 comments on “Open-source Arduino Clock”

Hi,
I am new in programming but interested in your project.Pls after compiling or verifying there is error ‘It’ is not declare in the scope ( for (int i=0; i&It;numBlinks; i++) {) {in the last but of the sketch.Can u kindly help me ?
thanks

Hi,
I’m working on a distributed control algorithm for quadrotors. Just by skimming through your code I see that the fastest you are writing to the serial port (i.e. to the Xbee) is every 1 second. And that is one packet. From their spec sheet Xbee’s (S2) can handle 250kbs. But that is per frame. The question I’m interested is how many packets can you write per second. If I have 200 bit frames can I write that say (approx) 1000 times a second to the Xbee? Can Xbee supprot 1000HZ on the serial port? If not, in your experience have you come across something that can handle this sampling rate?

A nice improvement is to add a battery backup at the Arduino’s power in fitting, so as to make it fully blackout-proof. Even better, you get to choose the size of the batteries.

Most alarm clocks with battery backup have a serious design flaw. It remembers the time, but if the blackout is right at the time the alarm is supposed to go off, it won’t. Almost as bad, clock radios with this feature default to a buzzer that is pathetically too weak.