Go Down

Topic: I made a clock. (Read 2355 times) previous topic - next topic


I've had a large 3" 7 segment display so took the opportunity of being snowed in for almost a week to turn it into a clock. It took about 3 long evenings to to the bulk of it and a lazy morning to get the bugs out of the sketch.

A bit scratched but still functional.

The segments are multiplexed and limiting resistors are iniluded on the PCB. But I got there in the end.

Even though the clock will be Arduino based I built a custom PCB rather than permanently use a useful Ardhuno board.

I used Eagle and it was a challenge to get all the components within the limited spade of the free version.

This is the resulting PCB with most of the components soldered in place.

The main PCB plugs straight onto the LED PCB.

This is the finished clock.

Code: [Select]

#include <Time.h>  

byte number[] = {  B01111110,  //0 Segments dp, a, b, c, d, e, f, g
                  B00110000,  //1
                  B01101101,  //2
                  B01111001,  //3
                  B00110011,  //4
                  B01011011,  //5
                  B00011111,  //6
                  B01110010,  //7
                  B01111111,  //8
                  B01110011,  //9
                  B01110111,  //A
                  //60,   //C
                  // 71,   //F
                  //103,   //E                    
byte segments[8]={9,10,11,12,13,14,15,16}; //dp, a, b, c, d, e, f, g
byte buttons[4]={1,2,3,4} ;//Control buttons 1=Hours inc, 2=hours dec, 3=mins inc, 4=minsdec
byte digit[4]={17,18,19,0} ;// Digit to display.
byte secs,secs1, secs10 ,mins,mins1,  mins10, hours, hours1, hours10 =0;
unsigned long timestamp;
#define multiplexDelay 5500 //microseconds.
#define buttonDelay 500 //delay between button scans.
unsigned long buttonStamp=0;
unsigned long dotStamp;
#define dotDelay 250
byte dot=0;
byte disp=0; //LED digit active.

void setup() {                
    pinMode(5, OUTPUT);

 for (int n=0;n<=7;n++){
    pinMode(segments[n], OUTPUT);
for (int n=0;n<=3;n++){
    pinMode(buttons[n], OUTPUT);

void loop() {
 secs=second ();
//  secs1=secs % 10; //Remainder = seconds.
//  secs10=secs / 10; //Remainder = 10s seconds.
   mins=minute ();
   mins1=mins % 10; //Remainder = minutes.
   mins10=mins / 10; //Remainder = 10s minutes.

   hours=hour ();
   hours1=hours % 10; //Remainder = hours.
   hours10=hours / 10; //Remainder = 10s hours.

if (micros()>timestamp){
     case (0):
     case (1):
     case (2):
     case (3):


void DispAdjust(){      // setTime(hr,min,sec,day,month,yr); // another way to set the time
int adjust=0;
 if (millis()>buttonStamp){
   if (digitalRead(buttons[0])==HIGH){
     if (adjust==24) adjust=0;      
     setTime(adjust,mins,secs,1,1,1990); // another way to set the time

   if (digitalRead (buttons[1])==HIGH){
     if (adjust==-1) adjust=23;
     setTime(adjust,mins,secs,1,1,1990); // another way to set the time
   if (digitalRead(buttons[2])==HIGH){
     if (adjust==61) adjust=0;      
     setTime(hours,adjust,secs,1,1,1990); // another way to set the time

   if (digitalRead (buttons[3])==HIGH){
     if (adjust==-1) adjust=59;
     setTime(hours,adjust,secs,1,1,1990); // another way to set the time


void Display(byte segment,byte num){
for (int n=0;n<=3;n++){
     digitalWrite (digit[n],LOW);
 digitalWrite (digit[segment],HIGH);

 for (int n=0;n<=7;n++){
     if( (number[num] & (128>>n)) !=0){
       digitalWrite (segments[n], HIGH);}
     else  {
       digitalWrite (segments[n], LOW);}

 if (millis()>dotStamp){
   if (dot==4) dot=0;

 if (dot==(3-segment)){
   digitalWrite (segments[0], HIGH);}
   digitalWrite (segments[0], LOW);

 if (disp>3) disp=0;


The Sketch uses the Time library which was easier to use then I first thought  ;)

This is a short video of it working.

Debugging was a bit tedious as I had to unplug and the Arduino chip and plug it into the Arduino board to reprogram it.

Its crrently hanging in the kitchen as is but when I get chance I'll get two sheets of rose tinted perspex to sandwich it between.


Nice! I'd like to do a large LED clock at some point too!   :D


Very nice :). Looks like a cool project. A few nights work sounds better then weeks work ;).

You could look at Ponoko and design your own custom enclosure. Probably a bit pricy though. Never used them myself but the example products look really nice, www.ponoko.com :).


How did you transfer the design onto the copper board? Photo resist, toner transfer or milled?


Milled on a converted Proxxon MF70. This is the just about the first serious PCB I've done since the conversion.


I thought it looked milled. I have just started doing this myself, with mixed results. Some success some failures all due to the cutting depth being too much or too little, and the flatness of the pcb on the milling table. I need more practice.

Go Up