单片机源程序如下:
- #include<reg51.h>
- #define uchar unsigned char
- #define uint unsigned int
- sbit SH_CP=P1^0;
- sbit DS=P1^1;
- sbit ST_CP=P1^2;
- uchar code tab[]=
- {
- /*-- 文字: 东 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x02,0x00,0x02,0x00,0x02,0x00,0x7F,0xFC,0x04,0x00,0x09,0x00,0x11,0x00,0x21,0x00,
- 0x3F,0xF8,0x01,0x00,0x09,0x20,0x11,0x10,0x21,0x08,0x41,0x04,0x05,0x00,0x02,0x00,
- /*-- 文字: 方 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x02,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x04,0x00,0x04,0x00,0x04,0x00,0x07,0xF0,
- 0x04,0x10,0x04,0x10,0x04,0x10,0x08,0x10,0x08,0x10,0x10,0x10,0x20,0xA0,0x40,0x40,
- /*-- 文字: 红 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x10,0x00,0x10,0x00,0x21,0xFC,0x24,0x20,0x44,0x20,0xF8,0x20,0x10,0x20,0x20,0x20,
- 0x40,0x20,0xFC,0x20,0x40,0x20,0x00,0x20,0x1C,0x20,0xE0,0x20,0x43,0xFE,0x00,0x00,
- /*-- 文字: 太 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00,0x01,0x00,
- 0x02,0x80,0x02,0x80,0x04,0x40,0x04,0x40,0x0A,0x20,0x11,0x10,0x21,0x08,0xC0,0x06,
- /*-- 文字: 阳 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0x7C,0x00,0x45,0xFC,0x49,0x04,0x49,0x04,0x51,0x04,0x49,0x04,0x49,0x04,
- 0x45,0xFC,0x45,0x04,0x45,0x04,0x69,0x04,0x51,0x04,0x41,0x04,0x41,0xFC,0x41,0x04,
- /*-- 文字: 升 --*/
- /*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x01,0x20,0x07,0xA0,0x3C,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0xFF,0xFE,
- 0x04,0x20,0x04,0x20,0x04,0x20,0x08,0x20,0x08,0x20,0x10,0x20,0x20,0x20,0x40,0x20,
- };
- uchar a[]={0x7f,0xff,0xbf,0xff,0xdf,0xff,0xef,0xff,0xf7,0xff,0xfb,0xff,0xfd,0xff,0xfe,0xff,
- 0xff,0x7f,0xff,0xbf,0xff,0xdf,0xff,0xef,0xff,0xf7,0xff,0xfb,0xff,0xfd,0xff,0xfe};
- void delayms(unsigned int ms)
- {
- uchar j;
- while(ms--)
- for(j=0;j<123;j++);
- }
- void writbyte(uchar dat)
- {
- uchar k;
- for(k=0;k<8;k++)
- {
- dat=dat<<1;
- DS=CY;
- SH_CP=0;
- SH_CP=1;
- }
- }
- void main()
- {
- uchar num,temp,n,m,count;
- while(1)
- {
- // for(n=0;n<6;n++)
- for(m=0;m<20;m++)//m移动速度
- {
- temp=0;
- for(num=0;num<16;num++)
- {
- writbyte(tab[2*(num+count)+1]);//行显示数据高8位
- writbyte(tab[2*(num+count)+0]);//低8位
- writbyte(a[2*temp+1]);//选择行高8位
- writbyte(a[2*temp]);//选择
- temp++;
- if(temp==16)
- {temp=0;}
- ST_CP=0;
- ST_CP=1;
- delayms(1);
- }
- }
- count++;
- if(count==80)
- {
- count=0;
- }
- }
-
- }
复制代码
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
新建文件夹.rar
(15.84 KB, 下载次数: 91)
|