新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 單片機(jī)程序匯編和C語言-LED燈的循環(huán)移動

單片機(jī)程序匯編和C語言-LED燈的循環(huán)移動

作者: 時間:2016-12-01 來源:網(wǎng)絡(luò) 收藏


本文引用地址:http://butianyuan.cn/article/201612/324131.htm
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 匯編&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
org 00h
start:mov r0,#8;
mov a,#11111110b;
loop:mov p1,a
rl a
call delay
djnz r0,loop
jmp start
DELAY: MOV R5,#20 ;延時子程序,延時0.2秒
D1: MOV R6,#20
D2: MOV R7,#248
DJNZ R7,$
DJNZ R6,D2
DJNZ R5,D1
RET
end

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&C 語言&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
#include
void delay100ms(); //如果函數(shù)是在主函數(shù)后面定義,那么一定要在主函數(shù)前面聲明
void main()
{
int i;
i=0xfe;
while(1)
{P1=i;
i--;
delay100ms();
if(i==0)
i=0xfe;
}
}
void delay100ms(void)//
{
unsigned char a,b,c;
for(c=19;c>0;c--)
for(b=20;b>0;b--)
for(a=230;a>0;a--);
}


評論


技術(shù)專區(qū)

關(guān)閉