编写一个跑马灯程序,用89C51单片机的P1.0到P1.7接八个LED
编写一个跑马灯程序,用89C51单片机的P1.0到P1.7接八个LED每个灯间隔时间0.5秒,跑完两圈后,加速变为0.2秒,再跑两圈后变为0.1秒要用定时来解决...
编写一个跑马灯程序,用89C51单片机的P1.0到P1.7接八个LED每个灯间隔时间0.5秒,跑完两圈后,加速变为0.2秒,再跑两圈后变为0.1秒
要用定时来解决 展开
要用定时来解决 展开
3个回答
展开全部
注意字符表未经验证, 请自行调试
#include <AT89X51.H>
#define uchar unsigned char
#define uint unsigned int
const unsigned char design[16]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x40,
0x20,0x10,0x08,0x04,0x02,0x10,0x00};
void delay_1ms(uint x)
{
uint i,j;
for (j=0;j<x;j++)
for (i=0;i<110;i++);
}
void set_led(uint jiange)
{
uchar i;
for (i=0;i<16;i++);
{
P1=design[i];
delay_1ms(jiange);
}
}
void main(void)
{
uint jg_ms;
jg_ms=500;
set_led(jg_ms);
jg_ms=200;
set_led(jg_ms);
jg_ms=500;
set_led(jg_ms);
}
#include <AT89X51.H>
#define uchar unsigned char
#define uint unsigned int
const unsigned char design[16]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x40,
0x20,0x10,0x08,0x04,0x02,0x10,0x00};
void delay_1ms(uint x)
{
uint i,j;
for (j=0;j<x;j++)
for (i=0;i<110;i++);
}
void set_led(uint jiange)
{
uchar i;
for (i=0;i<16;i++);
{
P1=design[i];
delay_1ms(jiange);
}
}
void main(void)
{
uint jg_ms;
jg_ms=500;
set_led(jg_ms);
jg_ms=200;
set_led(jg_ms);
jg_ms=500;
set_led(jg_ms);
}
展开全部
改下这个程序就可以了
ORG 0000H
START: LJMP MAIN
MAIN: MOV A, #0FFH
CPL ACC.0
LOOP: MOV P1, A
LCALL DELAY
RL A
LJMP LOOP
ORG 2000H
DELAY: MOV R4, #200
LOOP2: MOV R5, #248
LOOP3: DJNZ R5, LOOP3
DJNZ R4, LOOP2
RET
END
ORG 0000H
START: LJMP MAIN
MAIN: MOV A, #0FFH
CPL ACC.0
LOOP: MOV P1, A
LCALL DELAY
RL A
LJMP LOOP
ORG 2000H
DELAY: MOV R4, #200
LOOP2: MOV R5, #248
LOOP3: DJNZ R5, LOOP3
DJNZ R4, LOOP2
RET
END
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
注意字符表未经验证,
请自行调试
#include
<AT89X51.H>
#define
uchar
unsigned
char
#define
uint
unsigned
int
const
unsigned
char
design[16]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x10,0x00};
void
delay_1ms(uint
x)
{
uint
i,j;
for
(j=0;j<x;j++)
for
(i=0;i<110;i++);
}
void
set_led(uint
jiange)
{
uchar
i;
for
(i=0;i<16;i++);
{
P1=design[i];
delay_1ms(jiange);
}
}
void
main(void)
{
uint
jg_ms;
jg_ms=500;
set_led(jg_ms);
jg_ms=200;
set_led(jg_ms);
jg_ms=500;
set_led(jg_ms);
}
请自行调试
#include
<AT89X51.H>
#define
uchar
unsigned
char
#define
uint
unsigned
int
const
unsigned
char
design[16]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x10,0x00};
void
delay_1ms(uint
x)
{
uint
i,j;
for
(j=0;j<x;j++)
for
(i=0;i<110;i++);
}
void
set_led(uint
jiange)
{
uchar
i;
for
(i=0;i<16;i++);
{
P1=design[i];
delay_1ms(jiange);
}
}
void
main(void)
{
uint
jg_ms;
jg_ms=500;
set_led(jg_ms);
jg_ms=200;
set_led(jg_ms);
jg_ms=500;
set_led(jg_ms);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询