头像-161835

妖孽泪别

个人成就

获得 0 次赞

帮助过0人

24小时时钟加M蜂鸣器每到一小时响一次,四位数码管显示不出秒

24小时时钟加M蜂鸣器每到一小时响一次,用的是四位数码管,无法显示秒,

用89c51单片机编写时钟程序

#include <reg51.h>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();   }}利用这个程序改编,要求每10分、20分、30分整分数码管闪烁5秒

用89c51单片机编写时钟程序

#include <reg51.h>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();   }}这个程序可以显示四位数码管(分别显示小时、分),想利用这个程序再加一些程序,要求整点时蜂鸣器响5秒

用89c51单片机编写时钟程序

#include <reg51.h>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();   }}这个程序每步的解释