首页 > 编程知识 正文

单片机电子时钟代码(51单片机电子时钟)

时间:2023-05-05 15:28:56 阅读:70694 作者:3818

#includereg52.hsbit key1=P3^1; sbit key2=P3^0; sbit key3=P3^2; sbit key4=P3^3; sbit a=P2^2; //位选择声明sbit b=P2^3; sbit c=P2^4; Void延迟(Int; 语音中段(; 语音显示(int,int,int,int,int,int,int ); 语音密钥扫描(; //独立键char num[]={0x3f,0x 06,0x5b,0x4f,0x 66,0x6d,0x7d,0x 07,0x7f,0x6f}; char num2[]={0xbf,0x 86,0x db,0xcf,0x E6,0x ed,0xfd,0x 87,0x ff,0xef}; //带点数据的int shu1、shu2、shu3、shu4; //int ge,shi,fen1,fen2,hour1,hour2; int main () {TMOD=0x01; th0=(65536-45872 )/256; TL0=(65536-45872 ) 6; //th1=(65536-45872 )/256; //TL1=(65536-45872 ) 6; EA=1; ET0=1; //ET1=1; TR0=1; //TR1=1; 显示while(1)//display(ge,shi,fen1,fen2,hour1,hour2); keyscan (; }返回0; }voiddelay(intx ) {//timerint i,j; for(I=x; x0; x-- ) for(j=110; j0; j----; }voidzhongduan(interrupt1) th0=(65536-45872 )/256; TL0=(65536-45872 ) 6; 墅2; if(Shu2==20 ) ({ //1sshu2=0; shu1; if(Shu1==60 ) ) {shu3; shu1=0; (}shi=shu1/10; ge=shu1; if(Shu3==60 ) {shu4; shu3=0; (}fen1=shu3; fen2=shu3/10; if(Shu4==24 ) {shu4=0; }hour1=shu4; hour2=shu4/10; (//第一个if )//函数voiddisplay(intge,int shi,int fen1,int fen2,int hour1,int hour2) {P0=num[ge]; //秒位选择a=0//位选择b=0; c=0; dlay(1; P0=num[shi]; //秒选择10位a=1//位选择b=0; c=0; dlay(1; P0=num2[fen1]; //段选分位a=0; //位选择b=1; c=0; dlay(1; P0=num[fen2]; //段选分十位a=1; //位选择b=1; c=0; dlay(1; P0=num2[hour1]; //段选时位a=0; //位选择b=0; c=1; dlay(1; P0=num[hour2]; //段选时10位a=1; //位选择b=0; c=1; dlay(1; //FD=16 * 16 ^ 113 * 16 ^0=25613=269=1111101 void keyscan ((if ) key1==0) )5); if(key1==0) {shu4; if(Shu4==24 ) shu4=0; while (! key1; //等待密钥释放}if(key2==0) delay(5); if(key2==0) {shu3; if(Shu4=24 ) shu3=0; while (! key2; //}if(key3==0) ) delay ) 5; if(key3==0) {shu1=10; if(shu1=60 ) shu1=0; while (! ky3; }if(key4==0) ) delay ) 5; if(key4==0) {while (! ky4 ) TR0=~TR0; (}}//return 0; }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。