ORG 0000H
MOV 30H, #255
MOV 31H, #255
M_LOOP:
MOV R2, #8
DISP1:
MOV P1, 30H
MOV P2, 31H
CALL SHIFT1
CALL DL
DJNZ R2, DISP1
MOV R2, #8
DISP2:
MOV P1, 30H
MOV P2, 31H
CALL SHIFT2
CALL DL
DJNZ R2, DISP2
SJMP M_LOOP
-----------------------
SHIFT1:
CLR C
MOV A, 30H
RLC A
MOV 30H, A
CLR C
MOV A, 31H
RRC A
MOV 31H, A
RET
-----------------------
SHIFT2:
SETB C
MOV A, 31H
RLC A
MOV 31H, A
SETB C
MOV A, 30H
RRC A
MOV 30H, A
RET
-----------------------
DL:
DJNZ R7, $
DJNZ R7, $
DJNZ R6, $ - 4
RET
-----------------------
END
#include<reg52.h>#include <intrins.h>
void delayms(unsigned char ms) // 延时子程序
{
unsigned char i
while(ms--)
{
for(i = 0i <120i++)
}
}
main()
{
unsigned char LED
LED = 0xff
P0 = LED
while(1)
{
delayms(1000)
LED = LED<<1 //循环右移1位,点亮下一个LED
if(LED==0x00)
{
LED=0xff
}
P0 = LED
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)