仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
源码:
#include<reg51.h>
#include<intrins.h>
uchar hang[]=
{
0x00,0x01,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x80,
0x01,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x80,0x00,
};
uchar code lie[]=
{
/*-- 文字: 自 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFE,0xFF,0xFD,0xFF,0xFB,0xFF,0xE0,0x0F,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xE0,0x0F,
0xEF,0xEF,0xEF,0xEF,0xE0,0x0F,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xE0,0x0F,0xEF,0xEF,
/*-- 文字: 动 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFF,0xBF,0xFF,0xBF,0x83,0xBF,0xFF,0xBF,0xFE,0x03,0xFF,0xBB,0x01,0xBB,0xDF,0xBB,
0xDF,0xBB,0xDF,0x7B,0xB7,0x7B,0xBB,0x7B,0x02,0xFB,0xBA,0xFB,0xFD,0xD7,0xFB,0xEF,
/*-- 文字: 化 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xF7,0x7F,0xF7,0x7F,0xF7,0x7B,0xEF,0x77,0xEF,0x6F,0xCF,0x5F,0xCF,0x3F,0xAF,0x7F,
0x6E,0x7F,0xED,0x7F,0xEB,0x7F,0xEF,0x7D,0xEF,0x7D,0xEF,0x7D,0xEF,0x81,0xEF,0xFF,
/*-- 文字: 1 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF7,0xFF,0xC7,0xFF,0xF7,0xFF,0xF7,0xFF,0xF7,0xFF,
0xF7,0xFF,0xF7,0xFF,0xF7,0xFF,0xF7,0xFF,0xF7,0xFF,0xC1,0xFF,0xFF,0xFF,0xFF,0xFF,
/*-- 文字: 5 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x81,0xFF,0xBF,0xFF,0xBF,0xFF,0xBF,0xFF,0x87,0xFF,
0xBB,0xFF,0xFD,0xFF,0xFD,0xFF,0xBD,0xFF,0xBB,0xFF,0xC7,0xFF,0xFF,0xFF,0xFF,0xFF,
/*-- 文字: 0 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE7,0xFF,0xDB,0xFF,0xBD,0xFF,0xBD,0xFF,0xBD,0xFF,
0xBD,0xFF,0xBD,0xFF,0xBD,0xFF,0xBD,0xFF,0xDB,0xFF,0xE7,0xFF,0xFF,0xFF,0xFF,0xFF,
/*-- 文字: 1 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF7,0xFF,0xC7,0xFF,0xF7,0xFF,0xF7,0xFF,0xF7,0xFF,
0xF7,0xFF,0xF7,0xFF,0xF7,0xFF,0xF7,0xFF,0xF7,0xFF,0xC1,0xFF,0xFF,0xFF,0xFF,0xFF,
};
sbit sh0=P1^0;
sbit ds0=P1^1;
sbit st0=P1^2;
sbit sh1=P1^3;
sbit ds1=P1^4;
sbit st1=P1^5;
uchar i;
void delay(uchar z)
{
for(z;z>0;z--)
for(i=110;i>0;i--);
}
void send0(uchar temp0)
{
for(i=0;i<8;i++)
{
sh0=0;
ds0=temp0&0x80;
temp0=temp0<<1;
sh0=1;
}
}
void send1(uchar temp1)
{
for(i=0;i<8;i++)
{
sh1=0;
//ds1=temp1&0x80;
temp1=temp1<<1;
sh1=1;
}
}
void main()
{
uchar i=0,j,n=0;
uint m=0;
{
for(j=0;j<32;j++)
{
send0(hang[j]);
send1(lie[j+m]);
n++;
if(n==2)
{
st0=0;
st1=0;
_nop_();
st0=1;
st1=1;
n=0;
}
delay(2);
if((j+m)>288)
{
st0=0;
send0(0x00);
send0(0x00);
st0=1;
}
}
delay(110);
m+=2;
if(m==288)
m=0;
}
}
全部资料51hei下载地址:
LED点阵显示.rar
(63.88 KB, 下载次数: 129)
|