用汇编语言编写一个跑马灯音乐程序,用89C51单片机的P1.0到P1.7接八个LED
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
MOV A,#0FEH
START: RR A
MOV P1,A
CALL DELAY1
CJNE A,#0FEH,START
START1: RL A
MOV P1,A
CALL DELAY1
CJNE A,#7FH,START1
SJMP START
DELAY1: MOV R3,#50
D1: MOV R2,#4
D2: MOV R1,#248
DJNZ R1,$
DJNZ R2,D2
DJNZ R3,D1
RET
END
MOV A,#0FEH
START: RR A
MOV P1,A
CALL DELAY1
CJNE A,#0FEH,START
START1: RL A
MOV P1,A
CALL DELAY1
CJNE A,#7FH,START1
SJMP START
DELAY1: MOV R3,#50
D1: MOV R2,#4
D2: MOV R1,#248
DJNZ R1,$
DJNZ R2,D2
DJNZ R3,D1
RET
END
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询