跑马灯~
时间:10-02
整理:3721RD
点击:
刚入门,做的一个跑马灯程序,编译未报错,可是烧进去没有反应,求指导...该程序实现每隔100ms闪烁一次,八个led灯不断循环。
#include <reg52.h>
sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;
sbit ENLED = P1^4;
unsigned char i = 0;
unsigned char j = 0;
void InterruptTimer1() interrupt 3
{
TH1 = (65536-46080)/256;
TH0 = (65536-46080)%256;
i++;
}
unsigned char LED[] = {
0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F
};
void main()
{
ADDR0 = 0;
ADDR1 = 1;
ADDR2 = 1;
ADDR3 = 1;
ENLED = 0;
TMOD = 0x10;
TH1 = (65536-46080)/256;
TL1 = (65536-46080)%256; //50ms
TR1 = 1;
while (1)
{
if (i >= 2)
{
i = 0;
P0 = LED[j];
j++;
if (j > 7)
{
j = 0;
}
}
}
}
#include <reg52.h>
sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;
sbit ENLED = P1^4;
unsigned char i = 0;
unsigned char j = 0;
void InterruptTimer1() interrupt 3
{
TH1 = (65536-46080)/256;
TH0 = (65536-46080)%256;
i++;
}
unsigned char LED[] = {
0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F
};
void main()
{
ADDR0 = 0;
ADDR1 = 1;
ADDR2 = 1;
ADDR3 = 1;
ENLED = 0;
TMOD = 0x10;
TH1 = (65536-46080)/256;
TL1 = (65536-46080)%256; //50ms
TR1 = 1;
while (1)
{
if (i >= 2)
{
i = 0;
P0 = LED[j];
j++;
if (j > 7)
{
j = 0;
}
}
}
}