How to Make a Digital Clock Kit Based on Atmel

Introduction: How to Make a Digital Clock Kit Based on Atmel

This digtial clock kit comes with below features and functions:

Features
• Digital clock
• Counter
• Time alarm
• Stopwatch

Buttons
• S1: function selection button
• S2: extend function button
• S3: adjustment button

Functions:
Clock setting:  Press S1 once,you will see clock display flashing, Press S2 once to add 1  hour, Press S3 one to add 1 minute.

Alarm setting:  Press S1 twice,you will see colon keep light on, Press S2 once to add 1hour, Press S3 once to add 1 minute. It will turn off alarm when hour value over 23 and you will see --:--:--. Alarm will keep the buzzer on for 3 seconds.

Counter setting: Press S1 three times, you will see colon keep off and number show 0. Press S2 to select digit from lower end to higher end, then press S3 to add 1. It will start to count when you press S2 6th times.

Stopwatch:   Press S1 four times, you will see 00:00:00, colon keep on, press S2 once to start stopwatch, press S2 again to stop it. Press S3 to clear numbers.


<iframe width="420" height="315" src="http://www.youtube.com/embed/3VZpj4x8xc8" frameborder="0" allowfullscreen></iframe>



Step 1: All Materials You Need for This Kits

Here are the components you will need for this clock kit:

1 AT89C2051 U2
2 78L05 U1
3 12MHz Oscillator X3
4  2 digit 7segment display LED1
5 2 digit 7segment display LED2
6  2 digit 7segment display LED3
7 LED D2
8 LED D3
9 LED D4
10 LED D5
11 Buzzer  U7
12 CAP 30pF  C1
13 CAP 30pF C2
14 CAP 0.1uF (104) C3
15 CAP 0.1uF (104) C4
16 CAP 10uF C5
17 CAP 100uF C6
18 PNP 9012 Q1
19 PNP 9012 Q2
20 PNP 9012 Q3
21 PNP 9012 Q4
22 PNP 9012 Q5
23 PNP 9012 Q6
24 PNP 9012 Q7
25 Button S1
26 Button S2
27 BUTTON S3
28 Resistor 220 Ohm R1
29 Resistor 220 Ohm R2
30 Resistor 220 Ohm R3
31 Resistor 220 Ohm R4
32 Resistor 220 Ohm R5
33 Resistor 220 Ohm R10
34 Resistor 220 Ohm R11
35 Resistor 1K Ohm R12
36 Resistor 1K Ohm R13
37 Resistor 1K Ohm R14
38 Resistor 1K Ohm R15
39 Resistor 1K Ohm R16
40 Resistor 1K Ohm R17
41 Resistor 1K Ohm R18
42 Resistor 5.1K Ohm R19
43 Resistor 2K Ohm R7
44 Resistor 2K Ohm R8
45 Resistor 10K Ohm R6
46 2 pin connector J1
47 2 pin connector J2
48 2 pin connector J3
49 20pin DIP socket  -
50 PCB 50mmx105mm  -

All the parts can be found at here:
http://engineeringshock.com/6-digit-atmel-digital-clock-p-72.html?zenid=vrvei88auo6df1j11uoegk4s56

Step 2: Circuit Schematic and PCB

here is the schematic and PCB design

Step 3: A Sample of Source Code(C Language)

#include<REG2051.H>
code senen_seg[10]={0x81,0xe7,0x92,0xa2,0xe4,0xa8,0x88,0xe3,0x80,0xa0};
bit key1_enter=0,key2_enter=0,key3_enter=0,countdown_mark=0,stopwatch_mark=0,count_mark=0,bell_mark=0;
unsigned char program=0,program_variable=0,count_bit=0,count=0;
unsigned char hour=10,minute=10,second=0;
unsigned char delayed_hour=22,delayed_minute=10,delayed_second=0;
unsigned char count_hour=0,count_minute=0,count_second=0;
unsigned int count_time=0,count_count=0;
void delay(unsigned int t)
{
unsigned int i,j;
for(i=0;i<t;i++)
for(j=0;j<10;j++)
;
}
void time0_init(void){
EA=0;
TR0=0;
TMOD=0x02;
TH0=0x4;
TL0=0x4;
ET0=1;
TR0=1;
EA=1;
}

static void timer0_isr(void) interrupt TF0_VECTOR using 1
{
count_time++;
if(count_time>=4020){
count_time=0;
second++;
if(second>=60){
second=0;
minute++;
if(minute>=60){
minute=0;
hour++;
if(hour>=24)hour=0;
}
}
}
if(delayed_hour==hour && delayed_minute==minute && second<4) P3_7=0;
else P3_7=1;
if(countdown_mark==1){
count_count++;
if(count_count>=4000 && (count_second!=0|count_minute!=0|count_hour!=0)){
count_count=0;
count_second--;
if(count_second>=60){
count_second=59;
count_minute--;
if(count_minute>=60){
count_minute=59;
count_hour--;
if(count_hour>=100) count_hour=99;
}
}
}
if(count_second==0&&count_minute==0&&count_hour==0&&count_count<=12000) P3_7=0;
else P3_7=1;
if(count_count>=15000) count_count=14000;
}
if(stopwatch_mark==1){ count_count++;
if(count_count>=40){
count_count=0;
count_second++;
if(count_second>=100){
count_second=0;
count_minute++;
if(count_minute>=60){
count_minute=0;
count_hour++;
if(count_hour>=60) count_hour=0;
}
}
}
}
}
unsigned char show_key (void){
unsigned char x=0,y=0;
switch (program){
case 0: P1&=senen_seg[second%10]; 
break;
case 1: if(count_time>=2000) P1&=senen_seg[second%10]; 
break;
case 2: if(delayed_hour==24) P1=0xfe; 
else P1&=senen_seg[delayed_second%10];
break;
case 3: if(count_bit>=0) P1&=senen_seg[count_second%10];
else P1=0xff;
break;
case 4: P1&=senen_seg[count_second%10]; 
break;
case 5: P1&=senen_seg[count_second%10]; 
break;
}
P3_3=0;
delay(10);
if(P3_5==0){ 
key1_enter=1;
if(count<=254)count++;
}
if(P3_4==0) key2_enter=1;
if(P3_2==0) key3_enter=1; 
P3_3=1;
P1|=0xff;
switch (program){
case 0: P1&=senen_seg[second/10];
break;
case 1: if(count_time>=2000) P1&=senen_seg[second/10]; 
break;
case 2: if(delayed_hour==24) P1=0xfe; 
else P1&=senen_seg[delayed_second/10];
break;
case 3: if(count_bit>=1) P1&=senen_seg[count_second/10];
else P1=0xff;
break;
case 4: P1&=senen_seg[count_second/10];
break;
case 5: P1&=senen_seg[count_second/10];
break;
}
P3_1=0;
delay(10);
P3_1=1;
P1|=0xff;
switch (program){
case 0: P1&=senen_seg[minute%10];
break;
case 1: if(count_time>=2000) P1&=senen_seg[minute%10];
break;
case 2: if(delayed_hour==24) P1=0xfe;
else P1&=senen_seg[delayed_minute%10];
break;
case 3: if(count_bit>=2) P1&=senen_seg[count_minute%10];
else P1=0xff;
break;
case 4: P1&=senen_seg[count_minute%10];
break;
case 5: P1&=senen_seg[count_minute%10];
break;
}
P3_2=0;
delay(10);
P3_2=1;
P1|=0xff;
switch (program){
case 0: P1&=senen_seg[minute/10];
break;
case 1: if(count_time>=2000) P1&=senen_seg[minute/10];
break;
case 2: if(delayed_hour==24) P1=0xfe;
else P1&=senen_seg[delayed_minute/10];
break;
case 3: if(count_bit>=3) P1&=senen_seg[count_minute/10];
else P1=0xff;
break;
case 4: P1&=senen_seg[count_minute/10];
break;
case 5: P1&=senen_seg[count_minute/10]; 
break;
}
P3_5=0;
delay(10);
P3_5=1;
P1|=0xff;
switch (program){
case 0: P1&=senen_seg[hour%10];
break;
case 1: if(count_time>=2000) P1&=senen_seg[hour%10]; 
break;
case 2: if(delayed_hour==24) P1=0xfe;
else P1&=senen_seg[delayed_hour%10];
break;
case 3: if(count_bit>=4) P1&=senen_seg[count_hour%10];
else P1=0xff;
break;
case 4: P1&=senen_seg[count_hour%10]; break;
case 5: P1&=senen_seg[count_hour%10];
break;
}
P3_0=0;
delay(10);
if(P3_4==1 && key2_enter==1){
x=3; key2_enter=0;
}
P3_0=1;
P1|=0xff;
switch (program){
case 0: P1&=senen_seg[hour/10]; break;
case 1: if(count_time>=2000) P1&=senen_seg[hour/10]; break;
case 2: if(delayed_hour==24) P1=0xfe; else P1&=senen_seg[delayed_hour/10];
break;
case 3: if(count_bit>=5)P1&=senen_seg[count_hour/10]; else P1=0xff;
break;
case 4: P1&=senen_seg[count_hour/10];
break;
case 5: P1&=senen_seg[count_hour/10]; break;
}
P3_4=0;
delay(10);
if(P3_5==1 && key1_enter==1){
if(count>=127) x=1; else x=2; key1_enter=0;
count=0;
}
if(P3_2==1 && key3_enter==1){
x=4; 
key3_enter=0;
}
P3_4=1;
P1|=0xff;
if(program<=1 && count_time>=2000) P1&=0xff;
if(program<=1 && count_time<=2000) P1&=0x7f;
if(program==2) P1&=0x7f;
if(program==3) P1&=0xff;
if(program==4) P1&=0x7f;
if(program==5) P1&=0xff;
y=x;
x=0;
return y;
}
void main(){ 
P1=0xff;
P3=0xff;
time0_init();
while(1){
switch(program){
case 0: while(program==0){
switch(show_key()){
case 0: break;
case 1: program=0;
break;
case 2: program=1;
break;
}
}
break; 
case 1: while(program==1){
switch(show_key()){
case 0: break;
case 1: program=0;
break;
case 2: program=2;
break;
case 3: hour++;
if(hour>=24)hour=0;
break;
case 4: minute++;
if(minute>=60)minute=0;
break;
}
}
break;
case 2: while(program==2){
switch(show_key()){
case 0: break;
case 1: program=0;
break;
case 2: program=3;
break;
case 3: delayed_hour++;
if(delayed_hour>=25)delayed_hour=0;
break;
case 4: delayed_minute++;
if(delayed_minute>=60)delayed_minute=0;
break;
}
}
break;
case 3: while(program==3){ 
switch(show_key()){
case 0: break;
case 1: program=0;
break;
case 2: program=4;
break;
case 3: count_bit++;
if(count_bit>=7)count_bit=0;
break;
case 4: switch(count_bit){
case 0: count_second+=1;
break;
case 1: count_second+=10;
break;
case 2: count_minute+=1;
break;
case 3: count_minute+=10;
break;
case 4: count_hour+=1;
break;
case 5: count_hour+=10;
break;
case 6: break;
}
if(count_hour>=100) count_hour-=100;
if(count_minute>=60) count_minute-=60;
if(count_second>=60) count_second-=60;
break;
}
if(count_bit==6) countdown_mark=1;
else countdown_mark=0;
}
break;
case 4: count_hour=0; 
count_minute=0;
count_second=0;
while(program==4){
switch(show_key()){
case 0: break;
case 1: program=0;
break;
case 2: program=5;
break;
case 3: stopwatch_mark=~stopwatch_mark;
break;
case 4: if(stopwatch_mark==0){
count_hour=0;
count_minute=0;
count_second=0;
}
break;
}
}
break; 
case 5: count_hour=0;
count_minute=0;
count_second=0;
while(program==5){
switch(show_key()){
case 0: break;
case 1: program=0;
break;
case 2: program=0;
break;
case 3: count_second++;
if(count_second>=100){
count_second=0;
count_minute++;
if(count_minute>=100){
count_minute=0;
count_hour++;
if(count_hour>=100)count_hour=0;
}
}
break;
case 4: count_hour=0;
count_minute=0;
count_second=0;
break;
}
if(P3_7==0){
while(P3_7==0) show_key();
count_second++;
if(count_second>=100){
count_second=0;
count_minute++;
if(count_minute>=100){
count_minute=0;

Be the First to Share

    Recommendations

    • Puzzles Speed Challenge

      Puzzles Speed Challenge
    • "Can't Touch This" Family Contest

      "Can't Touch This" Family Contest
    • CNC Contest 2020

      CNC Contest 2020

    21 Discussions

    0
    MikeH524
    MikeH524

    Question 6 months ago

    How Do I troubleshoot the displays. Hours has 2 digits lit up, Minutes only 1 lit up (right digit) and Seconds only 1 digit lit up (left digit) . The clock does not seems to work. I bought six kits build 2 and none of them work. I have Partial lit up numbers and thats it
    Any suggestions
    Mike

    0
    Mikail115
    Mikail115

    1 year ago

    Could any body help me with Hex file?

    0
    vijay4488
    vijay4488

    3 years ago

    Please send me hex file on my email vijay2010jadhav@gmail.com

    0
    Sharmi2011
    Sharmi2011

    Reply 3 years ago

    i have hex file for that but dont have the diagram of the circuit .can any body send me the diagram to sharmidutta2011@gmail.com

    0
    jeflorez
    jeflorez

    Reply 2 years ago

    please. Send me the hex file to jedflorez@gmail.com . Thanks

    0
    HảiN2
    HảiN2

    Reply 2 years ago

    Please send me hex file. Thanks

    0
    PU1PBE
    PU1PBE

    Reply 2 years ago

    Would you please send the hex file to benjami@superig.com.br?

    0
    pandariv
    pandariv

    3 years ago

    Hey I want hex file and code of this clock project mail to pandarivittale@gmail.com

    0
    LukasN13
    LukasN13

    3 years ago

    Seriously? You can buy a kit at aliexpress for 2.60 or something like that, instructions included. Bought, works fine.

    0
    AdamH261
    AdamH261

    3 years ago

    The schematic is illegible. Is it possible to get a usable one?

    0
    solangi01
    solangi01

    4 years ago

    Please send me hex file on my email solangi01@gmail.com

    0
    jain7760
    jain7760

    4 years ago

    Please upload hex file

    0
    jain7760
    jain7760

    4 years ago

    HEX file Please

    0
    zanelegend
    zanelegend

    8 years ago on Step 2

    i would lvoe a better res of those scgematics too

    0
    ddato
    ddato

    8 years ago on Step 2

    do you have a better resolution for the schematic diagram? thanks