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, 0x37, 0x37, 0x3B, 0x3D, 0x7E },
{ 0xFF, 0x9C, 0x9B, 0x9B, 0x9B, 0x9D, 0x1E, 0x3F },
{ 0xFF, 0xCE, 0xCD, 0xCD, 0xCD, 0xCE, 0x0F, 0x1F },
{ 0xFF, 0x67, 0x66, 0x66, 0x66, 0x67, 0x07, 0x0F },
{ 0xFF, 0x33, 0x33, 0x33, 0x33, 0x33, 0x03, 0x87 },
{ 0xFF, 0x99, 0x99, 0x99, 0x99, 0x99, 0x81, 0xC3 },
{ 0xFF, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xC0, 0xE1 },
{ 0xFF, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE0, 0xF0 },
{ 0xFF, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF8 },
{ 0xFF, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF8, 0xFC },
{ 0xFF, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF8, 0xFC },
{ 0xFF, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF }
};
void main(void)
{
TMOD = 0x01;//定时器0设置为模式1
TH0 = 0xFC;//设置定时器0初始值,0.001s
TL0 = 0x67;
EA= 1;//中断总使能
ET0 = 1;//定时器0中断总使能
TR0 = 1;//启动定时器0
while(1);
}
void interrupt0() interrupt 1
{
static unsigned char i = 0;
static unsigned char index = 0;
static unsigned char tmr = 0;
TH0 = 0xFC;//设置定时器0初始值,0.001s
TL0 = 0x67;
P0 = 0xFF;//消除显隐
if (250 == tmr)
{
tmr = 0;
index++;
if (30 == index)
index = 0;
}
tmr++;
P1 = LedChar[i];
P0 = image[index][i];
i++;
if (8 == i)
i = 0;
}
250ms右移
#include <reg52.h>
unsigned char code LedChar[] =
{
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7
};
unsigned char code image[30][8] =
{
{ 0xFF, 0xFF, 0xFF, 0xFF, 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, 0x1F },
{ 0xFF, 0x67, 0x66, 0x66, 0x66, 0x67, 0x07, 0x0F },
{ 0xFF, 0x33, 0x33, 0x33, 0x33, 0x33, 0x03, 0x87 },
{ 0xFF, 0x99, 0x99, 0x99, 0x99, 0x99, 0x81, 0xC3 },
{ 0xFF, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xC0, 0xE1 },
{ 0xFF, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE0, 0xF0 },
{ 0xFF, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF8 },
{ 0xFF, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF8, 0xFC },
{ 0xFF, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF8, 0xFC },
{ 0xFF, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF }
};
void main(void)
{
TMOD = 0x01;//定时器0设置为模式1
TH0 = 0xFC;//设置定时器0初始值,0.001s
TL0 = 0x67;
EA= 1;//中断总使能
ET0 = 1;//定时器0中断总使能
TR0 = 1;//启动定时器0
while(1);
}
void interrupt0() interrupt 1
{
static unsigned char i = 0;
static unsigned char index = 29;
static unsigned char tmr = 0;
TH0 = 0xFC;//设置定时器0初始值,0.001s
TL0 = 0x67;
P0 = 0xFF;//消除显隐
if (250 == tmr)
{
tmr = 0;
if (0 == index)
index = 30;
index--;
}
tmr++;
P1 = LedChar[i];
P0 = image[index][i];
i++;
if (8 == i)
i = 0;
}
标签:动画,0x3F,0xE7,0xE6,0xF9,0xF3,0xFF,移动,点阵
From: https://www.cnblogs.com/EricsT/p/18538663