原创 16*16点阵滚动显示汉字

2011-6-1 12:36 20699 6 6 分类: MCU/ 嵌入式

/***程序:16*16点阵滚动显示汉字***/
/***作者:许彬***/
/***时间:2011.04.18***/
/***地点:华南理工大学***/

//程序说明
//四个8*8点阵组成16*16
//阴码,逐列扫描
//注意数据的放置
//作者:爱因斯尼 @SCUT
//时间:2010
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
#define data_hang P0
#define data_lieL P1//列扫描的低八位
#define data_lieH P2//列扫描的高八位
sbit LE1=P3^0;//列扫描的低八位
sbit LE2=P3^1;//列扫描的高八位
uchar code table1[]={
0xFF,0xFF,0x01,0x80,0x05,0x82,0x75,0x82,
0x75,0x8C,0x75,0xB0,0x05,0xA0,0x01,0xA0,
0x01,0xA0,0x05,0xA0,0x75,0xB0,0x75,0x8C,
0x75,0x82,0x05,0x82,0x01,0x80,0xFF,0xFF,/*"囧",0*/

0xFF,0xFF,0x01,0x80,0x05,0x80,0x75,0x80,
0x75,0x8E,0x75,0x91,0x05,0xA1,0x01,0xA2,
0x01,0xA2,0x05,0xA1,0x75,0x91,0x75,0x8E,
0x75,0x80,0x05,0x80,0x01,0x80,0xFF,0xFF,/*"笑脸",0*/


0xFF,0xFF,0x01,0x80,0x01,0x80,0x01,0x80,
0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
0x01,0x80,0x01,0x80,0x01,0x80,0xFF,0xFF,/*"圈8",0*/

0x00,0x00,0xFE,0x7F,0x02,0x40,0x02,0x40,
0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,
0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,
0x02,0x40,0x02,0x40,0xFE,0x7F,0x00,0x00,/*"圈7",0*/

0x00,0x00,0x00,0x00,0xFC,0x3F,0x04,0x20,
0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,
0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,
0x04,0x20,0xFC,0x3F,0x00,0x00,0x00,0x00,/*"圈6",0*/


0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x1F,
0x08,0x10,0x08,0x10,0x08,0x10,0x08,0x10,
0x08,0x10,0x08,0x10,0x08,0x10,0x08,0x10,
0xF8,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,/*"圈5",0*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xF0,0x0F,0x10,0x08,0x10,0x08,0x10,0x08,
0x10,0x08,0x10,0x08,0x10,0x08,0xF0,0x0F,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"圈4",0*/


0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xE0,0x07,0x20,0x04,0x20,0x04,
0x20,0x04,0x20,0x04,0xE0,0x07,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"圈3",0*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xC0,0x03,0x40,0x02,
0x40,0x02,0xC0,0x03,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"圈2",0*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,
0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"圈1",0*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xC0,0x03,0x40,0x02,
0x40,0x02,0xC0,0x03,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"圈2",0*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xE0,0x07,0x20,0x04,0x20,0x04,
0x20,0x04,0x20,0x04,0xE0,0x07,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"圈3",0*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xF0,0x0F,0x10,0x08,0x10,0x08,0x10,0x08,
0x10,0x08,0x10,0x08,0x10,0x08,0xF0,0x0F,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"圈4",0*/

0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x1F,
0x08,0x10,0x08,0x10,0x08,0x10,0x08,0x10,
0x08,0x10,0x08,0x10,0x08,0x10,0x08,0x10,
0xF8,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,/*"圈5",0*/

0x00,0x00,0x00,0x00,0xFC,0x3F,0x04,0x20,
0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,
0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,
0x04,0x20,0xFC,0x3F,0x00,0x00,0x00,0x00,/*"圈6",0*/

0x00,0x00,0xFE,0x7F,0x02,0x40,0x02,0x40,
0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,
0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,
0x02,0x40,0x02,0x40,0xFE,0x7F,0x00,0x00,/*"圈7",0*/

0xFF,0xFF,0x01,0x80,0x01,0x80,0x01,0x80,
0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
0x01,0x80,0x01,0x80,0x01,0x80,0xFF,0xFF,/*"圈8",0*/

0x20,0x04,0x30,0x04,0x18,0x04,0xFC,0x05,
0xFF,0x05,0x23,0x04,0x20,0x04,0x30,0xFF,
0x7F,0xFF,0xFF,0x04,0x88,0x04,0x8C,0x04,
0x86,0x04,0xE2,0x04,0xE0,0x04,0x00,0x04,/*"华",0*/

0x04,0x00,0xE4,0xFF,0xE4,0xFF,0x24,0x08,
0x64,0x09,0xE4,0x09,0xA4,0x09,0x3F,0x7F,
0x3F,0x7F,0xA4,0x09,0xE4,0x09,0x64,0x49,
0x24,0xC8,0xE4,0xFF,0xE4,0x7F,0x04,0x00,/*"南",1*/


0x8C,0x31,0x8C,0x31,0xFC,0x3F,0x8C,0x31,
0x8C,0x31,0x00,0x00,0xFC,0x60,0xFC,0x6C,
0xB4,0x6C,0xB4,0x6C,0xFC,0x7F,0xFC,0x7F,
0xB4,0x6C,0xB4,0x6C,0xFC,0x6C,0xFC,0x60,/*"理",2*/

0x00,0x20,0x04,0x20,0x04,0x20,0x04,0x20,
0x04,0x20,0x04,0x20,0x04,0x20,0xFC,0x3F,
0xFC,0x3F,0x04,0x20,0x04,0x20,0x04,0x20,
0x04,0x20,0x04,0x20,0x04,0x20,0x00,0x20,/*"工",3*/

0x20,0x80,0x20,0x80,0x20,0xC0,0x20,0x60,
0x20,0x30,0x20,0x1C,0x20,0x0F,0xFF,0x03,
0xFF,0x03,0x20,0x0F,0x20,0x1C,0x20,0x30,
0x20,0x60,0x20,0xC0,0x20,0x80,0x20,0x80,/*"大",4*/

0x40,0x04,0x70,0x04,0x31,0x04,0x97,0x04,
0x96,0x04,0x90,0x44,0x91,0xC4,0x97,0xFE,
0x96,0x7E,0x90,0x07,0x98,0x05,0x9C,0x04,
0x17,0x04,0x53,0x04,0x70,0x04,0x30,0x04,/*"学",5*/

0x00,0x00,0x00,0x00,0xF8,0x1F,0xF8,0x1F,
0x88,0x08,0x88,0x08,0x88,0x08,0xFF,0x7F,
0xFF,0xFF,0x88,0x88,0x88,0x88,0x88,0x88,
0xF8,0x9F,0xF8,0x9F,0x00,0xF0,0x00,0xF0,/*"电",6*/

0x80,0x00,0x82,0x00,0x82,0x00,0x82,0x00,
0x82,0x00,0x82,0x40,0x82,0xC0,0xE2,0xFF,
0xE2,0x7F,0xB2,0x00,0x9A,0x00,0x8E,0x00,
0x86,0x00,0x82,0x00,0x80,0x00,0x80,0x00,/*"子",7*/

0x00,0x08,0x00,0x08,0xE0,0x08,0xFF,0x08,
0x9F,0x08,0x88,0x08,0x88,0x08,0x88,0x08,
0x88,0x08,0x88,0x48,0x88,0xC8,0x88,0xC0,
0x88,0x7F,0x88,0x3F,0x08,0x00,0x00,0x00,/*"与",8*/

0x00,0x01,0x80,0x01,0xE0,0x00,0xF8,0xFF,
0xFF,0xFF,0x07,0x00,0x04,0x00,0x24,0xF9,
0x24,0xF9,0x25,0x49,0x27,0x49,0x26,0x49,
0x24,0x49,0x24,0xF9,0x24,0xF9,0x04,0x00,/*"信",9*/

0x00,0x40,0x00,0x70,0x00,0x30,0xFC,0x03,
0xFC,0x3B,0x54,0x79,0x56,0x41,0x57,0x45,
0x55,0x5D,0x54,0x59,0x54,0x41,0xFC,0x73,
0xFC,0x73,0x00,0x08,0x00,0x38,0x00,0x30,/*"息",10*/

0x40,0x04,0x70,0x04,0x31,0x04,0x97,0x04,
0x96,0x04,0x90,0x44,0x91,0xC4,0x97,0xFE,
0x96,0x7E,0x90,0x07,0x98,0x05,0x9C,0x04,
0x17,0x04,0x53,0x04,0x70,0x04,0x30,0x04,/*"学",11*/

0x00,0x00,0xFE,0xFF,0xFE,0xFF,0x7A,0x0C,
0xDE,0x0F,0x96,0x87,0x1C,0xC1,0x2C,0x71,
0x24,0x3F,0x25,0x0F,0x27,0x01,0x26,0x3F,
0x24,0x7F,0x34,0x41,0x1C,0x71,0x0C,0x71,/*"院",12*/

0x00,0x00,0xE0,0x0F,0xF0,0x1F,0x18,0x30,
0x08,0x20,0x18,0x30,0xF0,0x1F,0xE0,0x0F,/*"0",13*/

0x00,0x00,0x70,0x1C,0xF8,0x3E,0x88,0x23,
0x08,0x21,0x88,0x23,0xF8,0x3E,0x70,0x1C,/*"8",14*/

0x10,0x01,0x98,0x01,0xCC,0xFF,0xF7,0xFF,
0xB3,0xC0,0x9E,0x7E,0x9E,0x3E,0x9F,0x02,
0x9F,0x3E,0x9E,0x3E,0xBE,0x98,0xF8,0xEF,
0xDF,0x7F,0xF7,0x7F,0xF0,0xE7,0x10,0x80,/*"微",15*/

0x00,0x00,0x00,0x00,0xF8,0x1F,0xF8,0x1F,
0x88,0x08,0x88,0x08,0x88,0x08,0xFF,0x7F,
0xFF,0xFF,0x88,0x88,0x88,0x88,0x88,0x88,
0xF8,0x9F,0xF8,0x9F,0x00,0xF0,0x00,0xF0,/*"电",16*/

0x80,0x00,0x82,0x00,0x82,0x00,0x82,0x00,
0x82,0x00,0x82,0x40,0x82,0xC0,0xE2,0xFF,
0xE2,0x7F,0xB2,0x00,0x9A,0x00,0x8E,0x00,
0x86,0x00,0x82,0x00,0x80,0x00,0x80,0x00,/*"子",17*/

0x00,0x00,0xE0,0x0F,0xF0,0x1F,0x18,0x30,
0x08,0x20,0x18,0x30,0xF0,0x1F,0xE0,0x0F,/*"0",13*/


0x00,0x00,0x70,0x30,0x78,0x38,0x08,0x2C,
0x08,0x26,0x88,0x23,0xF8,0x31,0x70,0x30,/*"2",18*/

0x84,0x10,0x84,0x30,0xFC,0x3F,0xFC,0x1F,
0x84,0x88,0x84,0xCA,0xF8,0x63,0xF8,0x39,
0xFF,0x1F,0xFF,0x07,0x84,0x20,0x84,0x20,
0xFC,0x3F,0xFC,0x3F,0x84,0x20,0x84,0x20,/*"班",19*/

0x40,0x00,0x40,0x00,0x42,0x00,0xCE,0x7F,
0xCC,0x7F,0x00,0x30,0x20,0x11,0x38,0x01,
0x1F,0x01,0x0F,0x01,0xF8,0xFF,0xF8,0xFF,
0x08,0x01,0x08,0x01,0x08,0x01,0x00,0x01,/*"许",20*/

0x10,0x04,0x10,0x07,0xD0,0x03,0xFF,0xFF,
0xFF,0xFF,0x90,0x09,0x10,0x0F,0x90,0x07,
0xFF,0xFF,0xFF,0xFF,0x90,0x81,0x10,0xC3,
0x18,0x63,0x8C,0x31,0xE7,0x1C,0x63,0x0C,/*"彬",21*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
uint delay_time=10;
/***带形参的延时子函数**/
void delay(uint m)
{uint i,j;
for(i=0;i<m;i++)
     for(j=0;j<88;j++); }
/****只选通某一列***/
void Select_lie(uchar lie_data)
{
  if(lie_data<8)
     {
   P2=0xff;P1=0xfe<<lie_data|0xfe>>(8-lie_data);
   } 
  else
     {
   P1=0xff;P2=0xfe<<lie_data%8|0xfe>>(8-lie_data%8);
   }         
 }
/***逐个字***/
void show_start()
{
uint i,j,n,num;
for(j=0;j<3;j++)    //22个字
{n=(j-1)*16;
 
for(i=0;i<delay_time;i++)     //每个字显示的次数
{
for(num=n;num<n+16;num++)
{Select_lie(num%16);
 LE1=1;
 P0=table1[2*num];
 LE1=0;
 LE2=1;
 P0=table1[2*num+1];
 LE2=0;
 delay(3);
 }}
//LE1=LE2=1;
//P0=0X00;LE1=LE2=0;delay(500);
}//清屏
}
/***逐个字***/
void show_end()
{
uint i,j,n,num;
for(j=4;j<18;j++)    //22个字
{n=(j-1)*16;
 
for(i=0;i<delay_time;i++)     //每个字显示的次数
{
for(num=n;num<n+16;num++)
{Select_lie(num%16);
 LE1=1;
 P0=table1[2*num];
 LE1=0;
 LE2=1;
 P0=table1[2*num+1];
 LE2=0;
 delay(3);
 }}
//LE1=LE2=1;
//P0=0X00;LE1=LE2=0;delay(500);
}//清屏
}
/***左移***/
void show_author()
{
uint i,j,n,num;
for(j=273;j<611;j++)    //22个字
{n=j-1;
 
for(i=0;i<delay_time;i++)     //每个字显示的次数
{
for(num=n;num<n+16;num++)
{Select_lie((16-n+num)%16); //这里好纠结
 LE1=1;
 P0=table1[2*num];
 LE1=0;
 LE2=1;
 P0=table1[2*num+1];
 LE2=0;
 delay(3);
 }}
//LE1=LE2=1;
//P0=0X00;LE1=LE2=0;delay(500);
}//清屏
}
/***逐个字***/
void show_zhuzi()
{
uint i,j,n,num;
for(j=18;j<39;j++)    //22个字
{n=(j-1)*16;
 
for(i=0;i<delay_time;i++)     //每个字显示的次数
{
for(num=n;num<n+16;num++)
{Select_lie(num%16);
 LE1=1;
 P0=table1[2*num];
 LE1=0;
 LE2=1;
 P0=table1[2*num+1];
 LE2=0;
 delay(3);
 }}
//LE1=LE2=1;
//P0=0X00;LE1=LE2=0;delay(500);
}//清屏
}
/***擦除***/
void show_cachu()
{
uint i,j,n,num;
for(j=275;j<610;j++)    //22个字
{n=j-1;
 
for(i=0;i<delay_time;i++)     //每个字显示的次数
{
for(num=n;num<n+16;num++)
{
 Select_lie(num%16);
 LE1=1;
 P0=table1[2*num];
 LE1=0;
 LE2=1;
 P0=table1[2*num+1];
 LE2=0;
 delay(3);
 }}
//LE1=LE2=1;
//P0=0X00;LE1=LE2=0;delay(500);
}//清屏
}
void Int1_wai() interrupt 2 using 1
{
 if(delay_time>5)delay_time-=5;
 else
     {if(delay_time>0)delay_time--;
    else delay_time=20;}
 }
/*void Disp_moveleft()
{
uint i,j,n,num,g;
for(j=1;j<7;j++)
{n=(j-1)*16;
 
for(i=0;i<2;i++)
{
for(g=0;g<16;g++)    //左移
{  
for(num=n;num<n+16;num++)
{Select_lie(num%16);
 LE1=1;
 P0=table[2*num];
 LE1=0;
 LE2=1;
 P0=table[2*num+1];
 LE2=0;
 delay(3);}}}

}  }*/
/******数表字节转换********/
void word_change(uint change_num)
{uchar word_H,word_L;
 uint i;
 for(i=0;i<change_num;i++)
 {
  word_H=table1;
  word_L=table1[2*i+1];
  //table1=word_L;
 // table1[2*i+1]=word_H;
  }
 }
/*****主函数*****/
void main()
{uchar s;
EA=1;
EX1=1;
IT1=1;
while(1)
{for(s=0;s<14;s++)
     show_start();
  //delay_time=20;
    show_zhuzi();
    show_cachu();
 //delay_time=20;
    show_author();
 for(s=0;s<20;s++)
     show_end();
}
}

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
6
关闭 站长推荐上一条 /3 下一条