89C51
#include
sfr P1M0 =0x92;
sfr P1M1 =0x91;
char buf[4] ={0x01,0x02,3,4};
char hour=0,min=0,sec=0;
char code TAB[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
int time;
void delay(void){
unsigned int j;
j=1000;
for(;j--;);
}
unsigned int count=0;
void dir(void){
P0= TAB[buf[0]] ;
P1=0x08;
delay();
P0=0xff; //£¿£¿£¿
P1=0x02;
P0= TAB[buf[1]] ;
if(count>10)P0&=0x7f;
P1=0x02;
delay();
P0=0xff;
P1=0x04;
P0= TAB[buf[2]] ;
//if(count>10)P0&=0x7f;
delay();
P0=0xff;
P1=0x01;
P0= TAB[buf[3]] ;
delay();
P0=0xff;
P1=0x00;
}
void t1(void) interrupt 3 {
TL1= (char)(15536&0x00ff);
TH1= (char)(15536>>8);
count++;
if(count>19){
count=0;
//buf[3]++;
time++;
if(time>3599) time=0;
hour++
if(hour>23)
}
}
void main(void){
char min,sec;
hour
P1M0 =0x0f;
P1M1 =0x00;
TMOD=0x10;
TH1= (char)(15536>>8);
TL1= (char)(15536&0x00ff);
IE=0x88;
TR1=1;
while(1) {
min=(char)(time/60) ;
buf[0]=min/10; buf[1]=min%10;
sec=(char)(time%60) ;
buf[2]=sec/10; buf[3]=sec%10;
dir();
}
}
这个程序每步的解释
更多回帖