3个回答
展开全部
我只学过汇编!下面有两种效果。
第一种:
start:mov a,#0f0h
mov p1,a
call delay
mov a,#0fh
mov p1,a
call delay
sjmp start
delay:mov r7,#20
d1:mov r6,#200
d2:mov r5,#123
nop
djnz r5,$
djnz r6,d2
djnz r7,d1
ret
end
第二种:
start:mov a,#055h
mov p1,a
call delay
mov a,#0aah
mov p1,a
call delay
sjmp start
delay:mov r7,#20
d1:mov r6,#200
d2:mov r5,#123
nop
djnz r5,$
djnz r6,d2
djnz r7,d1
ret
end
第一种:
start:mov a,#0f0h
mov p1,a
call delay
mov a,#0fh
mov p1,a
call delay
sjmp start
delay:mov r7,#20
d1:mov r6,#200
d2:mov r5,#123
nop
djnz r5,$
djnz r6,d2
djnz r7,d1
ret
end
第二种:
start:mov a,#055h
mov p1,a
call delay
mov a,#0aah
mov p1,a
call delay
sjmp start
delay:mov r7,#20
d1:mov r6,#200
d2:mov r5,#123
nop
djnz r5,$
djnz r6,d2
djnz r7,d1
ret
end
展开全部
下列程序,有四个LED同时发光,使用PROTUSE验证了。
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar x;
void main()
{
TMOD = 0x01;
TH0 = (65536 - 50000) / 256;
TL0 = (65536 - 50000) % 256;
TR0 = 1;
ET0 = 1;
EA = 1;
x = 0;
P1 = 0x0F;
while(1);
}
void time0() interrupt 1
{
uchar a;
TH0 = (65536 - 50000) / 256;
TL0 = (65536 - 50000) % 256;
x++;
if(x == 20) {
x = 0;
a = P1;
a = _crol_(a, 1);
P1 = a;
}
}
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar x;
void main()
{
TMOD = 0x01;
TH0 = (65536 - 50000) / 256;
TL0 = (65536 - 50000) % 256;
TR0 = 1;
ET0 = 1;
EA = 1;
x = 0;
P1 = 0x0F;
while(1);
}
void time0() interrupt 1
{
uchar a;
TH0 = (65536 - 50000) / 256;
TL0 = (65536 - 50000) % 256;
x++;
if(x == 20) {
x = 0;
a = P1;
a = _crol_(a, 1);
P1 = a;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2009-12-06
展开全部
# include<reg51.h>
void delay()
{
unsigned int i;
for(i=0;i<20000;i++);
}
void main()
{
unsigned char index;
unsigned char LED;
while(1)
{
LED=0x01;
for(index=0;index<4;index++){
P1=LED;
LED<<=0x01;
delay();
}
}
}
void delay()
{
unsigned int i;
for(i=0;i<20000;i++);
}
void main()
{
unsigned char index;
unsigned char LED;
while(1)
{
LED=0x01;
for(index=0;index<4;index++){
P1=LED;
LED<<=0x01;
delay();
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询