脚本说明:
第一步:把如下代码加入<body>区域中
<SCRIPT language=javascript>
var dot=65
rads=new Array(65)
function rad () {
for (i=1; i<dot; i++) {
if (documentall) rads[i]=new Array (eval('rad'+i)style,-100,-100)
else rads[i] = new Array (eval('documentrad'+i),-100,-100)
}
}
function setCircle() {
for (i=1; i<dot; i++) {
rads[i][0]left=rads[i][1]+pX-15
if (documentlayers) rads[i][0]left+=10
rads[i][0]top=rads[i][2]+pY-20
//if (documentlayers) rads[i][0]top-=5
}
}
function counter() {
for (i=1; i<dot; i++) {
rad=MathPI(i/((dot-1)/2))
rads[i][1] = Mathsin(rad)60;
rads[i][2] = -Mathcos(rad)60;
}
setCircle()
}
pX=400;pY=150
obs = new Array(13)
function ob () {
for (i=0; i<13; i++) {
if (documentall) obs[i]=new Array (eval('ob'+i)style,-100,-100)
else obs[i] = new Array (eval('documentob'+i),-100,-100)
}
}
function cl(a,b,c){
if (documentall) {
if (a!=0) b+=-1
eval('c'+a+'stylepixelTop='+(pY+(c-5)))
eval('c'+a+'stylepixelLeft='+(pX+(b)))
}
else{
if (a!=0) b+=10
eval('documentc'+a+'top='+(pY+(c)))
eval('documentc'+a+'left='+(pX+(b)))
}
}
function runClock() {
for (i=0; i<13; i++) {
obs[i][0]left=obs[i][1]+pX
obs[i][0]top=obs[i][2]+pY
}
}
var lastsec
function timer() {
time = new Date ()
sec = timegetSeconds()
if (sec!=lastsec) {
lastsec = sec
sec=MathPIsec/30
min=MathPItimegetMinutes()/30
hr =MathPI((timegetHours()60)+timegetMinutes())/360
for (i=1;i<6;i++) {
obs[i][1] = Mathsin(sec) (44 - (i-1)11)-16;
if (documentlayers)obs[i][1]+=10;
obs[i][2] = -Mathcos(sec) (44 - (i-1)11)-27;
}
for (i=6;i<10;i++) {
obs[i][1] = Mathsin(min) (40 - (i-6)10)-16;
if (documentlayers)obs[i][1]+=10;
obs[i][2] = -Mathcos(min) (40 - (i-6)10)-27;
}
for (i=10;i<13;i++) {
obs[i][1] = Mathsin(hr) (37 - (i-10)11)-16;
if (documentlayers)obs[i][1]+=10;
obs[i][2] = -Mathcos(hr) (37 - (i-10)11)-27;
}
}
}
function setNum(){
cl (0,-67,-65);
cl (1,10,-51);
cl (2,28,-33);
cl (3,35,-8);
cl (4,28,17);
cl (5,10,35);
cl (6,-15,42);
cl (7,-40,35);
cl (8,-58,17);
cl (9,-65,-8);
cl (10,-58,-33);
cl (11,-40,-51);
cl (12,-16,-56);
}
</SCRIPT>
<DIV id=c0
style="HEIGHT: 128px; LEFT: 38px; POSITION: absolute; TOP: -119px; WIDTH: 686px; Z-INDEX: 2"></DIV>
<DIV id=c1
style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>1</B>
</DIV>
<DIV id=c2
style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>2</B>
</DIV>
<DIV id=c3
style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>3</B>
</DIV>
<DIV id=c4
style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>4</B>
</DIV>
<DIV id=c5
style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>5</B>
</DIV>
<DIV id=c6
style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>6</B>
</DIV>
<DIV id=c7
style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>7</B>
</DIV>
<DIV id=c8
style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>8</B>
</DIV>
<DIV id=c9
style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>9</B>
</DIV>
<DIV id=c10
style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>10</B>
</DIV>
<DIV id=c11
style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>11</B>
</DIV>
<DIV id=c12
style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><B>12</B>
</DIV>
<DIV id=ob0 style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 1">
</DIV>
<DIV id=ob1
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#0000ff size=+3><B></B></FONT> </DIV>
<DIV id=ob2
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#0000ff size=+3><B></B></FONT> </DIV>
<DIV id=ob3
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#0000ff size=+3><B></B></FONT> </DIV>
<DIV id=ob4
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#0000ff size=+3><B></B></FONT> </DIV>
<DIV id=ob5
style="HEIGHT: 32px; LEFT: -35px; POSITION: absolute; TOP: -4px; WIDTH: 742px; Z-INDEX: 8"><FONT
color=#0000ff size=+3><B></B></FONT> </DIV>
<DIV id=ob6
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#00ffff size=+3><B></B></FONT> </DIV>
<DIV id=ob7
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#00ffff size=+3><B></B></FONT> </DIV>
<DIV id=ob8
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#00ffff size=+3><B></B></FONT> </DIV>
<DIV id=ob9
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#00ffff size=+3><B></B></FONT> </DIV>
<DIV id=ob10
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 6"><FONT
color=#ff0000 size=+3><B></B></FONT> </DIV>
<DIV id=ob11
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 6"><FONT
color=#ff0000 size=+3><B></B></FONT> </DIV>
<DIV id=ob12
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 6"><FONT
color=#ff0000 size=+3><B></B></FONT> </DIV>
<DIV id=rad0 style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 1">
</DIV>
<DIV id=rad1
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad2
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad3
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad4
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad5
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad6
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad7
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad8
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad9
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad10
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad11
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad12
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad13
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad14
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad15
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad16
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad17
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad18
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad19
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad20
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad21
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad22
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad23
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad24
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad25
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad26
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad27
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad28
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad29
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad30
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad31
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad32
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad33
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad34
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad35
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad36
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad37
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad38
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad39
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad40
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad41
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad42
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad43
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad44
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad45
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad46
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad47
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad48
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad49
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad50
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad51
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad52
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad53
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad54
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad55
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad56
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad57
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad58
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad59
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad60
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad61
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad62
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad63
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
<DIV id=rad64
style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><FONT
color=#000000><B></B></FONT> </DIV>
第二步:把<body>中的内容改为:
<body onload="rad();counter();ob();setNum();setInterval('timer()',100);setInterval('runClock()',100)">
您可以登录我们的网站:(网站地址点击我们的百度账号名进入在我们的简介中有网址和我们的****)点击在线客服专员为您指导一下
朋友以下是本人历时一个月殚精竭虑自主开发的一个8位51单片机时钟程序,望吾之兄弟姐妹习之,此程序乃采用一键控制,通过感知按下键持续时间的长短来进行调整时间,闹铃,6只共阳数码管输出显示,此外还包括整点铃声功能,在看程序之前我先交代一下运行该程序的硬件要求:12M晶振,P0端口驱动显示,P20到P25控制显示扫描,P27输出铃声,注意:铃声功放三极管应采用pnp管。以下是该程序:
ORG 00H
SETB TR0
JMP START
ORG 000BH
LJMP T0
START: MOV IE,#82H
MOV TMOD,#01H
MOV DPTR,#TAB
MOV SP,#60H
MOV 20H,#0
MOV R0,#0
MOV R1,#0
MOV R2,#0
MOV R3,#0
MOV R4,#0
MOV R5,#0
MOV R6,#0
MOV R7,#0
MOV 50H,#0
MOV 51H,#0
MOV 52H,#0
MOV 53H,#0
MOV 54H,#0
MOV 55H,#0
MOV A,TL0
ADD A,0B5H
MOV TL0,A
MOV TH0,#3CH
LOOP: ANL 20H,#08H
UNSV: MOV R1,#0
LCALL DISPLAY
JB 03H,LOP1
LCALL SOUND
LCALL HDLY
LOP1: MOV P3,#0FEH ;按键监视
MOV A,P3
CJNE A,#0FEH,LOP2
MOV R1,#0
JMP LOOP
LOP2: MOV R1,#2 ;误按判断
LOP3: LCALL HD
DJNZ R1,LOP3
JNB 04H,LOOP
CLR 04H
LOP4: INC R1
MOV C,00H ;调秒
CPL C
MOV 00H,C
LCALL HDLY
CJNE R1,#40,LOP5
JMP LOOP
LOP5: JNB 05H,LOP4
CLR 05H
MOV R1,#0
LCALL HD
CLR 00H
JB 04H,TF
MOV R2,#0
MOV R3,#0
JMP LOP4
TF: CLR 04H
LOP6: INC R1
MOV C,01H ;调分
CPL C
MOV 01H,C
LCALL HDLY
CJNE R1,#40,LOP7
JMP LOOP
LOP7: JNB 05H,LOP6
CLR 05H
MOV R1,#0
LCALL HD
CLR 01H
JB 04H,TS
INC R4
MOV R1,#0
CJNE R4,#10,LOP6
MOV R4,#0
INC R5
CJNE R5,#6,LOP6
MOV R5,#0
JMP LOP6
TS: CLR 04H
LOP8: INC R1
MOV C,02H ;调时
CPL C
MOV 02H,C
LCALL HDLY
CJNE R1,#40,LOP9
JMP LOOP
LOP9: JNB 05H,LOP8
CLR 05H
MOV R1,#0
LCALL HD
CLR 02H
JB 04H,TN
INC R6
CJNE R7,#2,NO2
CJNE R6,#4,LOP8
MOV R7,#0
MOV R6,#0
NO2: CJNE R6,#10,LOP8
MOV R6,#0
INC R7
JMP LOP8
TN: CLR 04H ;调闹铃
SETB RS0
CLR RS1
MOV R2,#0
MOV R3,#0
MOV R4,#0
MOV R5,#0
MOV R6,#0
MOV R7,#0
NS: INC R1 ;闹铃秒调整
MOV C,00H
CPL C
MOV 00H,C
LCALL HDLY
CJNE R1,#40,NS1
JMP NH2
NS1: JNB 05H,NS
CLR 05H
MOV R1,#0
LCALL HD
CLR 00H
JB 04H,NF
INC R2
CJNE R2,#10,NS
MOV R2,#0
INC R3
CJNE R3,#6,NS
MOV R3,#0
JMP NS
NF: CLR 04H ;闹铃分
NF1: INC R1
MOV C,01H
CPL C
MOV 01H,C
LCALL HDLY
CJNE R1,#40,NF2
LJMP NH2
NF2: JNB 05H,NF1
CLR 05H
MOV R1,#0
LCALL HD
CLR 01H
JB 04H,NH
INC R4
CJNE R4,#10,NF1
MOV R4,#0
INC R5
CJNE R5,#6,NF1
MOV R5,#0
JMP NF1
NH: CLR 04H ;闹铃时调整
NH1: INC R1
MOV C,02H
CPL C
MOV 02H,C
LCALL HDLY
CJNE R1,#40,NH3
NH2: MOV 50H,R2
MOV 51H,R3
MOV 52H,R4
MOV 53H,R5
MOV 54H,R6
MOV 55H,R7
CLR RS0
CLR RS1
LJMP LOOP
NH3: JNB 05H,NH1
CLR 05H
MOV R1,#0
LCALL HD
CLR 02H
JB 04H,NH2
INC R6
CJNE R7,#2,NOT2
CJNE R6,#4,NH1
MOV R6,#0
MOV R7,#0
JMP NH1
NOT2: CJNE R6,#10,NH1
MOV R6,#0
INC R7
JMP NH1
;子程序区
TIMES: CJNE R0,#20,LOOP16
MOV R0,#0
INC R2
CJNE R2,#10,LOOP16
MOV R2,#0
INC R3
CJNE R3,#6,LOOP16
MOV R3,#0
ADMINI: INC R4
CJNE R4,#10,LOOP16
MOV R4,#0
INC R5
CJNE R5,#6,LOOP16
MOV R5,#0
HOUR: INC R6
LCALL SOUND ;整点铃声
CJNE R7,#2,LOOP14
CJNE R6,#4,LOOP16
MOV R6,#0
MOV R7,#0
JMP LOOP16
LOOP14: CJNE R6,#10,LOOP16
MOV R6,#0
INC R7
LOOP16: RET
DISPLAY:MOV P2,#0FFH
MOV A,R2
MOVC A,@A+DPTR
MOV P0,A
MOV C,00H
MOV P20,C
MOV P2,#0FFH
MOV A,R3
MOVC A,@A+DPTR
MOV P0,A
MOV P21,C
MOV P2,#0FFH
MOV A,R4
MOVC A,@A+DPTR
MOV P0,A
MOV C,01H
MOV P22,C
MOV P2,#0FFH
MOV A,R5
MOVC A,@A+DPTR
MOV P0,A
MOV P23,C
MOV P2,#0FFH
MOV A,R6
MOVC A,@A+DPTR
MOV P0,A
MOV C,02H
MOV P24,C
MOV P2,#0FFH
MOV A,R7
MOVC A,@A+DPTR
MOV P0,A
MOV P25,C
MOV P2,#0FFH
RET
HDLY: MOV 40H,#2
HDL1: MOV 41H,#25
HDL2: MOV 42H,#100
HDL3: DJNZ 42H,HDL4
DJNZ 41H,HDL2
DJNZ 40H,HDL1
JMP HDOT
SOUT: SETB 05H
HDOT: RET
HDL4: MOV P3,#0FEH
MOV A,P3
CJNE A,#0FEH,SOUT
CLR 05H
LCALL DISPLAY
JMP HDL3
HD: MOV 30H,#5
HD1: MOV 31H,#50
HD2: MOV 32H,#100
HD3: LCALL DISPLAY
DJNZ 32H,HD4
DJNZ 31H,HD2
DJNZ 30H,HD1
SETB 04H ;计满标志位
JMP HDOUT
HD4: MOV P3,#0FEH
MOV A,P3
CJNE A,#0FEH,HD3
MOV 33H,#50
HD5: MOV 34H,#100
DJNZ 34H,$
DJNZ 33H,HD5
MOV P3,#0FEH
MOV A,P3
CJNE A,#0FEH,HD3
CLR 04H
HDOUT: RET
SOUND: MOV 30H,#10
SO1: MOV 31H,#100
SO2: MOV 32H,#3
MOV C,P27
CPL C
MOV P27,C
SO3: MOV 33H,#25
DJNZ 33H,$
DJNZ 32H,SO3
DJNZ 31H,SO2
DJNZ 30H,SO1
RET
T0: PUSH PSW
PUSH ACC
CLR RS1
CLR RS0
MOV A,TL0
ADD A,#0B5H
MOV TL0,A
MOV TH0,#3CH
INC R0
LCALL TIMES
MOV A,R2
CJNE A,50H,TO
SETB 03H
MOV A,R3
CJNE A,51H,TO
MOV A,R7
CJNE A,55H,TO
MOV A,R6
CJNE A,54H,TO
MOV A,R5
CJNE A,53H,TO
MOV A,R4
CJNE A,52H,TO
MOV A,R2
ADD A,R3
ADD A,R4
ADD A,R5
ADD A,R6
ADD A,R7
JZ TO
CLR 03H
TO: POP ACC
POP PSW
RETI
TAB: DB 0C0H 0F9H 0A4H 0B0H 099H
DB 092H 082H 0F8H 080H 090H
END
以上就是关于制作一个时钟显示程序全部的内容,包括:制作一个时钟显示程序、51单片机时钟程序设计、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)