近日从电路板上拆下一批无字库的LCD12864液晶屏,为了测试屏的好坏,特地写了测试程序,结果几十块屏全部都是好的!
先来看看实物图片
正面
背面
引脚功能
时序图与LCD1602一样
大汉字取模方法
最终效果图
只要加入时间和18B20温度传感器,就成时钟和温度计
部分主要程序
12864初始化:
lcd12864.c
- sbit e=P3^4;
- sbit rw=P3^6;
- sbit rs=P3^5;
- sbit cs1=P3^7;
- sbit cs2=P3^3;
- sbit duan=P2^7; //定义74H373的控制引脚,
- sbit wei=P2^6;
- void lcd12864_write_com(uchar com) //写指令
- {
- rs=0;rw=0;e=0;
- P0=com;
- e=1;
- delay(5);
- e=0;
- }
- void lcd12864_write_date(uchar date)//写数据
- {
- rs=1;rw=0;e=0;
- P0=date;
- e=1;
- delay(5);
- e=0;
- }
- void lcd12864_init() //初始化
- {
- lcd12864_write_com(0xc0); //行的初始化地址
- lcd12864_write_com(0xb8);//页的初始化地址
- lcd12864_write_com(0x40);//列的初始化地址
- lcd12864_write_com(0x3f);//打开屏幕 ,关闭是3e
- }
- void clear_lcd12864() //清屏
- {
- uchar i,j;
- cs1=1;cs2=1; //打开左右两屏,实物 注意:LCD12864实物是CS1=1;CS2=1为打开,
- for(i=0;i<8;i++) //共8页
- {
- lcd12864_write_com(0xb8+i);//页的初始化地址
- lcd12864_write_com(0x40);//列的初始化地址
- for(j=0;j<64;j++) //共64列
- {
- lcd12864_write_date(0x00);
- }
- }
- }
复制代码
12864显示程序:
lcd12864dis.c
- /***********大汉字数组,取模方式32X32*****************/
- uchar code tab[][128]={
- //好好学习天天向上
- /***********0-好*****************/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x78,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0xE0,0x70,0x60,0x00,0x00,0x00,0x00,
- 0x00,0x02,0x02,0x02,0x02,0xE2,0xFF,0x0F,0x02,0x02,0x02,0xF2,0xFF,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xFC,0x02,0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x20,0x3C,0x27,0x40,0x40,0xC0,0xE0,0xFE,0x8F,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,
- 0x00,0x40,0x40,0x20,0x10,0x08,0x0C,0x06,0x03,0x01,0x01,0x03,0x07,0x0E,0x00,0x00,0x10,0x10,0x30,0x30,0x70,0x3F,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"好",0*/
- /***********1-好*****************/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x78,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0xE0,0x70,0x60,0x00,0x00,0x00,0x00,
- 0x00,0x02,0x02,0x02,0x02,0xE2,0xFF,0x0F,0x02,0x02,0x02,0xF2,0xFF,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xFC,0x02,0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x20,0x3C,0x27,0x40,0x40,0xC0,0xE0,0xFE,0x8F,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,
- 0x00,0x40,0x40,0x20,0x10,0x08,0x0C,0x06,0x03,0x01,0x01,0x03,0x07,0x0E,0x00,0x00,0x10,0x10,0x30,0x30,0x70,0x3F,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"好",1*/
- /***********2-学*****************/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x70,0xE0,0xC0,0x00,0x00,0x04,0x38,0xF0,0xE0,0x00,0x00,0x00,0x00,0xC0,0x70,0x3C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x60,0x7C,0x3C,0x04,0x84,0x84,0x85,0x85,0x84,0x84,0x84,0x84,0x85,0x84,0x84,0x84,0x84,0x87,0xC5,0xC4,0x84,0x04,0x24,0x14,0x1E,0x0E,0x04,0x00,0x00,
- 0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xFC,0xF8,0x24,0x24,0x22,0x21,0x21,0x20,0x20,0x20,0x20,0x30,0x38,0x30,0x20,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x30,0x70,0x3F,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"学",2*/
- /***********3-习*****************/
- {0x00,0x00,0x00,0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xE0,0xF0,0x20,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x04,0x0C,0x18,0x78,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0x60,0x20,0x30,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x02,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x08,0x08,0x08,0x18,0x38,0x38,0x1F,0x07,0x00,0x00,0x00,0x00,0x00,0x00},/*"习",3*/
- /***********4-天*****************/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xE0,0xE0,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x38,0x30,0x20,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xFF,0xFF,0x40,0xC0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x60,0x70,0x60,0x40,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x70,0x3E,0x0F,0x00,0x00,0x03,0x0C,0x30,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x40,0x40,0x20,0x30,0x10,0x08,0x04,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x06,0x0E,0x1C,0x38,0x38,0x10,0x10,0x10,0x00},/*"天",4*/
- /***********5-天*****************/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xE0,0xE0,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x38,0x30,0x20,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xFF,0xFF,0x40,0xC0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x60,0x70,0x60,0x40,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x70,0x3E,0x0F,0x00,0x00,0x03,0x0C,0x30,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x40,0x40,0x20,0x30,0x10,0x08,0x04,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x06,0x0E,0x1C,0x38,0x38,0x10,0x10,0x10,0x00},/*"天",5*/
- /***********6-向*****************/
- {0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x3C,0x1C,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x80,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0xFF,0x01,0x01,0x01,0x01,0x01,0xE1,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0xC1,0xE1,0x41,0x01,0x01,0x01,0x01,0xFF,0xFF,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0xFF,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x10,0x10,0x30,0x78,0x3F,0x0F,0x00,0x00,0x00,0x00},/*"向",6*/
- /***********7-上*****************/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xF8,0x08,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,0xFF,0xFF,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x38,0x30,0x20,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0x1F,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x18,0x1C,0x1C,0x18,0x10,0x00},/*"上",7*/
- };
- /***********标准汉字数组,取模方式16X16*****************/
- uchar code tab_biao[][32]={
- /*********0-----好***************/
- {0x00,0x10,0x10,0xF0,0x1F,0x10,0xF0,0x00,0x80,0x82,0x82,0xE2,0x92,0x8A,0x86,0x80,
- 0x00,0x40,0x22,0x15,0x08,0x16,0x61,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00},
- /*********1-----好***************/
- {0x00,0x10,0x10,0xF0,0x1F,0x10,0xF0,0x00,0x80,0x82,0x82,0xE2,0x92,0x8A,0x86,0x80,
- 0x00,0x40,0x22,0x15,0x08,0x16,0x61,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00},
- /*********2-----学***************/
- {0x00,0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,
- 0x00,0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x04,0x04},
- /*********3-----习***************/
- {0x00,0x00,0x02,0x02,0x02,0x12,0x22,0xC2,0x02,0x02,0x02,0x02,0x02,0xFE,0x00,0x00,
- 0x00,0x00,0x08,0x18,0x08,0x04,0x04,0x04,0x02,0x02,0x41,0x81,0x40,0x3F,0x00,0x00},
- /*********4-----“:”***************/
- {0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x7B,0x7B,0x7B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
- /*********5-----心形***************/
- {0x00,0xE0,0x10,0x10,0x10,0x30,0x40,0x80,0x80,0x40,0x20,0x10,0x10,0x10,0xF0,0x00,
- 0x00,0x03,0x04,0x08,0x10,0x20,0x20,0x40,0x40,0x20,0x20,0x10,0x08,0x04,0x03,0x00},
- };
- /*********小数字数组:半列显示,取模方式16X8***************/
- uchar code tab_banlie[][16]={
- /*********0***************/
- {0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
- 0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00},
- /*********1***************/
- {0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,
- 0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00},
- /*********2***************/
- {0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,
- 0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00},
- /*********3***************/
- {0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,
- 0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00},
- /*********4***************/
- {0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,
- 0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00},
- /*********5***************/
- {0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,
- 0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00},
- /*********6***************/
- {0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,
- 0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00},
- /*********7***************/
- {0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,
- 0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00},
- /*********8***************/
- {0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,
- 0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00},
- /*********9***************/
- {0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
- 0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00},
- /*********10--Q***************/
- {0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,
- 0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00},
- };
- /***********大汉字显示函数************************/
- void hanzi(uchar ye,uchar lie,uchar *shuzhu) //定义任意页、任意列、任意数组(*表示指针类型)
- {
- uchar i,j;
- for(i=0;i<4;i++) //4页
- {
- lcd12864_write_com(0xb8+ye+i);//页的初始化地址
- lcd12864_write_com(0x40+lie);//列的初始化地址
- for(j=0;j<32;j++) //这里要显示大汉字,取模为32X32
- {
- lcd12864_write_date(shuzhu[i*32+j]);
- }
- }
- }
- /***********标准汉字显示函数************************/
- void hanzi2(uchar ye,uchar lie,uchar *shuzhu) //定义任意页、任意列、任意数组(*表示指针类型)
- {
- uchar i,j;
- for(i=0;i<2;i++) //2页
- {
- lcd12864_write_com(0xb8+ye+i);//页的初始化地址
- lcd12864_write_com(0x40+lie);//列的初始化地址
- for(j=0;j<16;j++) //这里要显示标准汉字,取模为16X16
- {
- lcd12864_write_date(shuzhu[i*16+j]);
- }
- }
- }
- /***********小数字显示函数************************/
- void shuzi2(uchar ye,uchar lie,uchar *shuzhu) //定义任意页、任意列、任意数组(*表示指针类型)
- {
- uchar i,j;
- for(i=0;i<2;i++) //2页
- {
- lcd12864_write_com(0xb8+ye+i);//页的初始化地址
- lcd12864_write_com(0x40+lie);//列的初始化地址
- for(j=0;j<8;j++) //数字取半模,这里要改为8
- {
- lcd12864_write_date(shuzhu[i*8+j]);
- }
- }
- }
- void lcd12864_dis() //汉字显示函数
- {
- /*******显示第一行***********/
- cs1=1;cs2=0;//打开左半屏 ,实物
- shuzi2(0,0,tab_banlie[10]);// Q
- shuzi2(0,8,tab_banlie[10]);// Q
- hanzi2(0,16,tab_biao[4]); //":"
- shuzi2(0,32,tab_banlie[1]);// 1
- shuzi2(0,40,tab_banlie[2]);// 2
- shuzi2(0,48,tab_banlie[3]);// 3
- shuzi2(0,56,tab_banlie[4]);// 4
- cs1=0;cs2=1;//打开右半屏 ,实物
- shuzi2(0,0,tab_banlie[5]);// 5
- shuzi2(0,8,tab_banlie[6]);// 6
- shuzi2(0,16,tab_banlie[7]);// 7
- shuzi2(0,24,tab_banlie[8]);// 8
- shuzi2(0,32,tab_banlie[9]);// 9
- /*******显示第二行(标准汉字)***********/
- cs1=1;cs2=0;//打开左半屏 ,实物
- hanzi2(2,0,tab_biao[0]); //好
- hanzi2(2,16,tab_biao[1]); //好
- hanzi2(2,32,tab_biao[2]); //学
- hanzi2(2,48,tab_biao[3]); //习
- cs1=0;cs2=1;//打开右半屏 ,实物
- hanzi2(2,32,tab_biao[5]); // 心
- /*******显示第三行(大汉字)***********/
- cs1=1;cs2=0;//打开左半屏 ,实物
- hanzi(4,0,tab[4]); //天
- hanzi(4,32,tab[5]); //天
- cs1=0;cs2=1;//打开右半屏 ,实物
- hanzi(4,0,tab[6]); //向
- hanzi(4,32,tab[7]); //上
- }
复制代码
全部资料51hei下载地址:
无字库LCD12864液晶同时显示大小汉字含全部资料.rar
(7.27 MB, 下载次数: 237)
|