《AT89C52单片机一分钟计时伴随led闪烁的C程序》由会员分享,可在线阅读,更多相关《AT89C52单片机一分钟计时伴随led闪烁的C程序(4页珍藏版)》请在金锄头文库上搜索。
1、#include #define uchar unsigned char #define uint unsigned intsbit led=P00;uchar num,num1,num2,ge,shi;uchar code table= 0XCO,0XF9,0XA4,0XB0,0X99,0X92,0X82 ,0XF8,0X80,0X90,0X88,0X83,0XC6,0XA1,0X86,0X8E void fuwei() P2=0XA0;P0=0X8F;P2=0X00; void delayms()uint i,j;for(i=xms;i0;i-)for (j=110;j0;j-);void
2、 display(uchar shi,uchar ge )P2=0XE0;P0=tableshi;P2=0X00;P0=0X00;P2=0XC0;P0=0X01;P2=0X00;delayms(5);P2=0XE0;P0=tablege;P2=0X00;P2=0X00;P2=0XC0;P0=0X02;P0=0X00;delayms(5);void main()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);void T0_time() interrupt 0TH0=(65536-45872)/256;TH0=(65536-45872)/256;num1+;if(num1=10)num1=0;P2=0X90;led=led;void T1_time() interrupt 3TH0=(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;