新网站制作公司,电子商务是干什么的就业前景,本地人wordpress怎么同步到服务器,电脑建站软件本例介绍一种用LED制作的电脑电子钟#xff08;电脑万年历#xff09;。其制作完成装潢后的照片如下图#xff1a; 上图中#xff0c;年、月、日及时间选用的是1.2寸共阳数码管#xff0c;星期选用的是2.3寸数码管#xff0c;温度选用的是0.5寸数码管#xff0c;也可根据…本例介绍一种用LED制作的电脑电子钟电脑万年历。其制作完成装潢后的照片如下图 上图中年、月、日及时间选用的是1.2寸共阳数码管星期选用的是2.3寸数码管温度选用的是0.5寸数码管也可根据个人的爱好选用不同规格的数码管。原理图如下图所示 上图中CPU选用的是AT89C2051,时钟芯片选用的是Dallas公司的DS1302,温度传感器选用的是Dallas公司的数字温度传感器DS1820显示驱动芯片选用的是德州仪器公司的TPIC6B595,也可选用与其兼容的芯片NC595或国产的AMT9595。整个电子钟用两个键来调节时间和日期。一个是位选键一个是数字调节键。按一下位选键头两位数字开始闪动进入设定调节状态此时按数字调节键当前闪动位的数字就可改变。全部参数调节完后五秒钟内没有任何键按下则数字停止闪动退出设定调节状态。
源程序清单如下无温度显示程序
start:do;$includereg51.dcldeclare sclk,io,rst bit at 0b3h register; /* p33,p34,p35 */declare command,data,n,temp1,num byte;declare a9 byte;declare ab6 byte;declare aco11 byte constant 0fdh,60h,0dah,0f2h,66h,0b6h,0beh,0e0h,0feh,0f6h,00hdeclare week11 byte constant 0edh,028h,0dch,7ch,39h,75h,0f5h,2ch,0fdh,7dh,00hdeclare da literally p15,clk literally p16,ale literally p17,mk literally p11,sk literally p12;clear:procedure;sclk0;io0;rst0;end clear;send1302:procedurecommdeclare i,comm byte;do i0 to 7;commscrcomm,1iocy;call time1sclk0;call time1sclk1;end;end send1302;wbyt1:procedurecom,dat/*字节写过程*/declare com,dat byte;call clear;rst1;call send1302comcall send1302datcall clear;end wbyt1;wbyt8:procedure;/*时钟多字节突发模式写过程*/declare j byte;call clear;a7A6a6a0rst1;call send1302commanddo j1 to 8;call send1302ajend;call clear;end wbyt8;RBYT1:PROCEDURE;DECLARE I BYTE;CALL CLEAR;RST1;call send13020c1hIO1;DO I0 TO 7;SCLK1;SCLK0;CYIO;NSCRN,1END;A8N;CALL CLEAR;END RBYT1;send595:procedure;declare k byte;do k0 to 7;datascrdata,1dacy;clk1;clk0;end;end send595;send595_1:procedure;declare k byte;do k0 to 7;datascrdata,1da1cy;clk11;clk10;end;end send595_1;rb1:procedureabc,jDECLARE I,j,abc BYTE;CALL CLEAR;RST1;call send1302abcIO1;DO I0 TO 7;SCLK1;SCLK0;CYIO;NSCRN,1END;abjN;abjdecabjCALL CLEAR;end rb1;rbyt6:procedure;call rb10f1h,0call rb10f3h,1call rb10f5h,2call rb10f7h,3call rb10f9h,4call rb10fbh,5call rb10fdh,6end rbyt6;wbyt6:procedure;call wbyt18eh,0/* write enable */call wbyt10f0h,ab0call wbyt10f2h,ab1call wbyt10f4h,ab2call wbyt10f6h,ab3call wbyt10f8h,ab4call wbyt10fah,ab5call wbyt10fch,ab6call wbyt18eh,80h/* write disable */end wbyt6;rbyt8:procedure;/*时钟多字节突发模式读过程*/declare i,j byte;call clear;rst1;call send1302commandio1;do j1 to 8;do i0 to 7;sclk1;call time1sclk0;cyio;nscrn,1end;ajn;end;call clear;a0a6a6A7a0a0 and 0fh;if a06 then a00;CALL RBYT1;if a10 and a20 and a30 thendo;do num0 to 35;call time250end;temp11;end;if temp11 thendo;temp10;ab4ab41;if ab499h thendo;ab40;ab5ab51;if ab599h then ab50;end;call wbyt6;end;end rbyt8;display:procedure; /*jieya,yima,fasong*/declare i,n,m byte;na0 and 0fh; /* send week */dataweekncall send595;na4/* send date */nn and 0fh;dataaconcall send595;na4nshrn,4dataaconcall send595;do i1 to 3; /* send second,minute,hour */nainn and 0fh;dataaconcall send595;nainshrn,4dataaconcall send595;end;do i5 to 6; /* send month,year */nainn and 0fh;dataaconcall send595;nainshrn,4dataaconcall send595;end;na8/* send 19 or 20 */nn and 0fh;dataaconcall send595;na8nshrn,4dataaconcall send595;do m0 to 5;nabmnn and 0fh;dataaconcall send595_1;nabmnshrn,4dataaconcall send595_1;end;ale0;ale1;end display;beginset:procedure;a006h;a158h;a259h;a323h;a430h;a506h;a697h;a700;a819h; /* set date/time 1997,7,1,8:00:00,week 3 */call wbyt18eh,0/* write enable*/call wbyt180h,00h/* start colock */call wbyt10beh,0abh/*两个二极管与8K电阻串联充电*/command0beh; /* write colock/date */call wbyt8;call wbyt10c0h,a8call wbyt18eh,80h/* set write protect bit */end beginset;key:procedure;declare i,time1,k1,tem byte;call time100k17;time130;if mk0 thendo;do while time10;week: if k10 thendo;do i0 to 5;/* call hza0*/end;do i0 to 3;/* call hz0; */end;end;temak1if k17 then tema8ak10aah;if k17 then a80aah;call display;call time254call time 254ak1tem;if k17 then a8tem;call display;call time254call time254call time254time1time1-1;if mk0 thendo;call time100/*MOD KEY PROCESS*/TIME130;IF MK0 THENDO;k1k1-1;DO WHILE K10FFH;K17;END;END;end;IF SK0 THENDO;CALL TIME100/*SET KEY PROCESS*/TIME130;IF SK0 THENDO;temtem1;temdectemDO CASE K1;DO WHILE tem7;/*week*/tem0;END;DO WHILE tem60H;/*scond*/tem0;END;DO WHILE tem60H;/*minute*/tem0;END;DO WHILE tem24H;/*hour*/tem0;END;DO WHILE tem32H;/*date*/tem1;END;DO WHILE tem13H;/*month*/tem1;END;DO while tem100h; /* YEAR */tem00;END;DO WHILE TEM21H;tem19H;END;END;AK1tem;if k17 then a8tem;END;END;END;END;end key;main$program:mk1;sk1;temp10;num0;p321;if sk0 then call beginset;clk0;da0;ale1;loop:do while mk1 ;if a06 then a00;command0bfh;call rbyt8;call display;do while mk0;call key;call wbyt18eh,0command0beh;call wbyt8;call wbyt10C0H,A8call wbyt18eh,80hend;end;goto loop;end start;