汉字流水灯显示,简单的汉字就可以了。我下面一段程序,我编译下载后,
单片机运行,8*8点阵是乱的。为什么?
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar C_cross[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar R_cross[10][8]={
{0x00,0x42,0x46,0x4a,0x52,0x62,0x42,0x00},//"Z"
{0x00,0x40,0x40,0x7e,0x40,0x40,0x00,0x00},//"T"
{0x7e,0x20,0x10,0x08,0x10,0x20,0x7e,0x00},//"M"
{0x00,0x42,0x42,0x7e,0x42,0x42,0x00,0x00},//"I"
{0x30,0x48,0x44,0x32,0x44,0x48,0x30,0x00},//"LOVE"
{0x00,0x80,0x40,0x3e,0x40,0x80,0x00,0x00}, //"Y"
{0x30,0x28,0x14,0x38,0x38,0x14,0x28,0x30},//"LOVE,LOVE"
{0x00,0x80,0x40,0x3e,0x40,0x80,0x00,0x00}, //"Y"
{0x00,0x20,0x20,0x1e,0x10,0x20,0x20,0x00}, //"R"
{0x00,0x7e,0x42,0x42,0x42,0x24,0x18,0x00} //"D"
};
uchar offset;
uchar n;
void Delayms(uchar mt)
{
uchar t;
for(mt;mt>0;mt--)
for(t=110;t>0;t--);
}
void main(void)
{
uchar i;
uchar *p;
n=0;
TMOD=0x01;
TH0=0xfc;
TL0=0x18;
ET0=1;
EA=1;
TR0=1;
p=&R_cross[0][0];
while(1)
{
for(i=0;i<8;i++)
{
Delayms(10000);
P0=*(p+offset);
P2=C_cross;
p++;
if(p>&R_cross[0][7])
p=&R_cross[0][0];
}
}
}
void
timer0() interrupt 1 using 3
{
TF0=0;
TH0=0xfc;
TL0=0xe18;
if(n<200)
{
n++;
}
else
{
n=0;
offset+=1;
if(offset>72)
offset=0;
}
}
我后来找了单片机附赠的静态显示程序,这个可以调试成功,显示一个心形
/*copyright 2007,ShangHai HaoTun Electronic Technology co.,Ltd
*
*This sample is used for 7-seg led dynamic display .
*
*write by Shifang 2007-4-23
*
*V1.1
*/
#include <reg52.h>
unsigned char const dofly[]={0x00,0x6C,0x92,0x82,0x44,0x28,0x10,0x00};// 心的形状
unsigned char code seg[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};//分别对应相应的段亮
////////////////////////////////////////////////////////
void delay(unsigned int cnt)
{
while(--cnt);
}
///////////////////////////////////////////////////////
main()
{
unsigned char i;
while(1)
{
P0=dofly
;//取显示数据
P2=seg; //取段码
delay(200); //扫描间隙延时
i++;
if(8==i)
i=0;
}
}
这二者间,我还是搞不懂,怎么由静态转为动态,求大神指导~
我知道有字符生成软件,关键怎么让他动起来呢?
一周热门 更多>