自己编写的千分秒计时器,C语言编写的51单片机实例,
#include
#include
#define uint unsigned int
#define uchar unsigned char
uchar aa,bai,shi,ge;
int temp;
sbit dula=P2^6;
sbit wela=P2^7;
sbit key1=P3^4;
sbit key2=P3^5;
sbit key3=P3^6;
sbit key4=P3^7;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uint a,b;
void init();
void delay(uint z)
{
uint t1,y;
for(t1=z;t1>0;t1--)
for(y=110;y>0;y--);
}
void display(uchar bai,uchar shi,uchar ge); void main()
{
init();
//display(bai,shi,ge);
a=0;
while(1)
{
bai=temp/100;
shi=temp%100/10;
ge=temp%10;
if(key4==0)
{
TR0=1;
temp=0;
display(bai,shi,ge);
}
if(key1==0)
delay(5);