1、0x66 , 0x6d , 0x7d , 0x07 ,0x7f , 0x6f , 0x77 , 0x7c,0x39 , 0x5e , 0x79 , 0x71;uchar numl, num2, s, si, m, ml, f, fl, num, numf, nums, dingshi;uchar ns, nsl, nf, nf 1, numns, numnf;void delay(uint z);void keyscan ();void keyscanl ();void alram(); void display(uchar m, uchar ml, uchar f, ucharf1, uch
2、ars, ucharsl); void displayO(uchar nf, uchar nf1, uchar ns, uchar nsl);void main()TMOD二0x01;/设定定时器0工作方式1THO=(65536-46080)/256 ;TLO=(65536-46080)%256 ;EA二1;/开总中断ETO=1;/开定时器0中断TRO二1;/启动定时器0中断numns=12;numnf=0;while (1)if(dingshi=0)keyscan ();display (m, ml, f, fl, s, si);alram();elsekeyscanl ();display
3、O (nf, nf 1, ns, nsl);void keyscan ()if (keyl=0)delay(10);if(keyl=0)nums+;if (nums=:=24)nums二0;while (!keyl);if(key2=0)if (key2=0)numf+;if (numf=60)numf=O;key2);display(m, ml, f, fl, s, si);if(key3=0)delay (10);dingshi二dingshi;while(!key3)/* if(key4=0)if(key4=0)flag二1;key4);*/void keyscanl()delay 仃0
4、);numns+;if (numns=24)numns=0;/ display (nf, nf 1, ns, nsl);numnf+;if (numnf60)dingshiO;wh订e(!key3);void alramOif(numnf=numf)&(numns二二nums)beep二0;if (numnf+l=:numf) & (numnsnums) & (dingshiO) / 一分钟报时提示beep=l;void displayO (uchar nf, uchar nf 1, uchar ns, uchar nsl)/闹钟显 示函数nf=numnf%10;nfl=numnf/10;ns
5、=:numns%10;nsl 二 numns./10;/* wela=l;P0=0xc0; /送位选数据wela=0;P0二Oxff;*/dula=l;PO二tablensl;dula=0;PO二Oxff;wela=l;PO二Oxfe;delay (1);PO二tablens 0x80;PO=Oxff;PO二Oxfd;delay (1);P0=table Lnf1;PO=Oxfb;wela=O;PO=tablenf;dula=O;P0=0xf7;void display(uchar m, uchar ml, uchar f, ucharfl, uchars, ucharsl) /时间显示PO二
6、table ml ; /秒位第 1 位/秒位第2位/时位第一位PO=Oxef; wela=O; delay (1);Portable Im; dula=0; wela=l;PO二Oxdf; wela=0;P0=tablesi;Portable s 0x80;delay(1);P0=table fl : /分位第一位we la二0;PO二tablef 0x80;void T0_timer() interrupt 1TH0=(65536-46080)/256 ;TL0=(65536-46080)%256 ; num2+;if (num2=20)num+;num2=0;m=:num%10;ml二num/10;f=numf%10;f1二numf/10;s=nums%10;signums/10;if (num59)numO;if(numf二二59)if (nums二二24) nums=O;void delay(uint z)uint x, y;for (x=110;x0;x-)for (y=z;yy一一);
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1