您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 其它相关文档 > AT89C52单片机一分钟计时伴随led闪烁的C程序
#includereg52.h#defineucharunsignedchar#defineuintunsignedintsbitled=P0^0;ucharnum,num1,num2,ge,shi;ucharcodetable[]={0XCO,0XF9,0XA4,0XB0,0X99,0X92,0X82,0XF8,0X80,0X90,0X88,0X83,0XC6,0XA1,0X86,0X8E}voidfuwei(){P2=0XA0;P0=0X8F;P2=0X00;}voiddelayms(){uinti,j;for(i=xms;i0;i--)for(j=110;j0;j--);}voiddisplay(ucharshi,ucharge){P2=0XE0;P0=table[shi];P2=0X00;P0=0X00;P2=0XC0;P0=0X01;P2=0X00;delayms(5);P2=0XE0;P0=table[ge];P2=0X00;P2=0X00;P2=0XC0;P0=0X02;P0=0X00;delayms(5);}voidmain(){TMOD=0X01;TH0=(65536-45872)/256;TH0=(65536-45872)/256;EA=1;ET0=1;ET1=1;TR0=0;TR1=0;while(1){display(ge,shi);}}voidT0_time()interrupt0{TH0=(65536-45872)/256;TH0=(65536-45872)/256;num1++;if(num1==10){num1=0;P2=0X90;led=~led;}}voidT1_time()interrupt3{TH0=(65536-45872)/256;TH0=(65536-45872)/256;num2++;if(num2==20){num2=0;num++;if(num==60){num=0;ge=num%10;shi=num/10;}}}
本文标题:AT89C52单片机一分钟计时伴随led闪烁的C程序
链接地址:https://www.777doc.com/doc-7237197 .html