Home > other >  Based on 51 single chip microcomputer digital tube display digital clock design
Based on 51 single chip microcomputer digital tube display digital clock design

Time:09-22

The design parameter
1. The timing function is realized by using a timer;
2. Digital tube for display;
3. Can realize buttons adjust time function;
4. With the function of alarm,
The
The end of the 20th century, obtained the rapid development of electronic technology, under the push, the modern electronic products almost permeated all fields of society, vigorously promoted the development of social productivity and the enhancement of social information degree, at the same time also make into step, improve the modern electronic products performance and product update rhythm also more and more fast,

MCU module is most common in digital clock, digital clock is a - kind of digital circuit technology, points, second timing device, has higher accuracy compared with the mechanical clock and intuitive, and no mechanical device, has a longer service life, therefore has been widely used,

This subject mainly research the design of digital clock is based on single chip microcomputer, AT89C51 single chip microcomputer as main control chip of the system, and external LED display circuit, key circuit, crystals circuit, reset circuit module consists of a simple digital clock, through the key circuit can pair, points, second set and real-time adjustment, respectively, and will be showed on the digital tube,

Keywords: digital clock, single-chip microcomputer, digital tube

This topic is mainly involves a crystal vibration circuit, reset circuit, digital tube driver circuit, control circuit keys
1. The crystals circuit, reset circuit
2. Digital tube driver circuit (mainly is composed of 74 hc573 and 74 hc138 chip)
3. The key control circuit

About the rest of the code section
First you need pin and variables
 typedef unsigned int u8; 
Typedef unsigned long under-16;

Sbit LSA=P2 ^ 0;
Sbit LSB=P2 ^ 1;
Sbit LSC=P2 ^ 2;
Sbit bz P1=^ 3;//define a buzzer pin
Sbit k1=P3 ^ 0;//define P30 mouth is k1
Sbit k2=P3 ^ 1;//define P31 mouth is k2
Sbit k3=P3 ^ 2;//define P32 mouth is k3
Sbit k4=P3 ^ 3;//define P33 mouth is k4
The static under-16 s=16;//to hour assignment
The static under-16 f=30;//to minutes assignment
The static under-16 m=0;//to the second assignment
The static under-16 n=2020;//to year assignment
The static under-16 y=1;//to month assignment
The static under-16 r=1;//to day assignment

The static under-16 m1=0;//to the alarm clock second assignment
The static under-16 s1=16;//give alarm clock hour assignment
The static under-16 f1=31;//give alarm clock minutes assignment
The static under-16 n1=2020;//to the alarm clock in assignment
The static under-16 y1=1;//for the alarm clock on assignment
The static under-16 r1=1;//to the alarm clock, assignment
The static under-16 KB=0;//to make ling response time assignment
The static under-16 kb1=0;//to make ling response time assignment


Then write 138 chip driver function
 void xs1 () 
{
U8 I;
for(i=0; i<8; I++)
{
The switch (I)
{
Case (0) :
LSA=0; LSB=0; LSC=0; break;
Case (1) :
LSA=1; LSB=0; LSC=0; break;
Case (2) :
LSA=0; LSB=1; LSC=0; break;
Case (3) :
LSA=1; LSB=1; LSC=0; break;
Case (4) :
LSA=0; LSB=0; LSC=1; break;
Case (5) :
LSA=1; LSB=0; LSC=1; break;
Case (6) :
LSA=0; LSB=1; LSC=1; break;
Case (7) :
LSA=1; LSB=1; LSC=1; break;
}
P0=a, [I].
Delay (20);
P0=0x00;
}
}


The following is a function of the relation between the time and date
 void dy1p () 
{
If (m> 59)
{
M=0;
F++;
If (f>=60)
{
f=0;
S++;
If (s> 23)
{
S=0;
}
}
}
}

Void dy1 ()//show time
{
Dy1p ();
A [0]=wg [10] s/;
A [1]=wg [10] % s.
A, [2]=0 x00.
A [3]=wg [10] f/;
A [4]=wg [10] f %;
A, [5]=0 x00.
A [6]=wg [10] m/;
A [7]=wg [m] % 10;
Xs1 ();
}

Void dy2p ()
{
If (s> 23)
{
R++;
If (r> 30)
{
R=0;
Y++;
If (y> 12)
{
y=0;
N++;
}
}
}
}

Void dy2 ()//show (date) (month) (year)
{
Dy2p ();
A [0]=wg [n/1000];
A [1]=wg 10] [n/100%;
A [2]=wg 10] [n/10%;
A [3]=wg [10] n %;
A [4]=wg [10] y/;
A [5]=wg [10] y %;
A [6]=wg [10] r/;
A [7]=wg [10] r %;
Xs1 ();
}

Void dy3p ()
{
If (m1 & gt; 59)
{
M1=0;
F1 + +;
If (f1 & gt;=60)
{
F1=0;
S1 + +;
If (s1 & gt; 23)
{
S1=0;
}
}
}
}

Void dy3 ()//display the alarm clock time
{
Dy3p ();
A [0]=wg [10] s1/;
A [1]=wg [10] s1 %;
A, [2]=0 x00.
A [3]=wg 10]/[f1;
A [4]=wg % 10] [f1;
A, [5]=0 x00.
A [6]=wg [10] m1/;
A [7]=wg [10] m1 %;
Xs1 ();
}


Then write the key regulating function
 void keypros1 ()//minute adjustment function 
{
M=0;
While (1)
{
If (k2==0)
{
delay(1000);
If (k2==0)
{
F++;
If (f> 59)
{
f=0;
}
}
while(! K2);
}
If (k3==0)
{
delay(1000);
If (k3==0)
{
F -;
If (f<1)
{
f=0;
}
}
while(! K3);
}
Dy1 ();
If (k4==0)
{
delay(1000);
If (k4==0)
{
break;
}
while(! K4);
}
}

}

Void keypros2 ()//hour adjustment function
{
While (1)
{
If (k2==0)
{
delay(1000);
If (k2==0)
{
S++;
If (s> 23)
{
S=0;
}
}
while(! K2);
}
If (k3==0)
{
delay(1000);
If (k3==0)
{
S -;
If (f<1)
{
S=0;
}
}
while(! K3);
}
Dy1 ();
If (k4==0)
{
delay(1000);
If (k4==0)
{
break;
}
while(! K4);
}
}
}

Void keypros3 ()//number of the regulating function
{
While (1)
{
If (k2==0)
{
delay(1000);
If (k2==0)
{
R++;
If (r> 30)
{
R=0;
}
}
while(! K2);
}
If (k3==0)
{
delay(1000);
If (k3==0)
{
R -;
If (r<1)
{
R=0;
}
}
while(! K3);
}
Dy2 ();
If (k4==0)
{
delay(1000);
If (k4==0)
{
break;
}
while(! K4);
}
}
}

Void keypros4 ()//months adjustment function
{
While (1)
{
If (k2==0)
{
delay(1000);
If (k2==0)
{
Y++;
If (y> 12)
{
Y=1;
}
}
while(! K2);
}
If (k3==0)
{
delay(1000);
If (k3==0)
{
y--;
If (y<2)
{
Y=1;
}
}
while(! K3);
}
Dy2 ();
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related