找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 7518|回复: 10
收起左侧

无字库LCD12864液晶同时显示大小汉字,有图有单片机程序含全部资料

  [复制链接]
ID:110903 发表于 2018-9-6 21:35 | 显示全部楼层 |阅读模式
近日从电路板上拆下一批无字库的LCD12864液晶屏,为了测试屏的好坏,特地写了测试程序,结果几十块屏全部都是好的!
先来看看实物图片
正面
LCD12864实物7.png

背面
LCD12864实物6.png

引脚功能
SG12864J4.png

时序图与LCD1602一样
1602时序图.png

大汉字取模方法
大汉字取模方法.jpg

最终效果图
截图00.png

只要加入时间和18B20温度传感器,就成时钟和温度计
截图01.png

部分主要程序
12864初始化:
lcd12864.c
  1.   sbit e=P3^4;
  2.   sbit rw=P3^6;
  3.   sbit rs=P3^5;
  4.   sbit cs1=P3^7;
  5.   sbit cs2=P3^3;
  6.   sbit duan=P2^7;  //定义74H373的控制引脚,
  7.   sbit wei=P2^6;
  8.   void lcd12864_write_com(uchar com) //写指令
  9.   {
  10.   rs=0;rw=0;e=0;
  11.   P0=com;
  12.   e=1;
  13.   delay(5);
  14.   e=0;
  15.   }

  16.   void lcd12864_write_date(uchar date)//写数据
  17.   {
  18.   rs=1;rw=0;e=0;
  19.   P0=date;
  20.   e=1;
  21.   delay(5);
  22.   e=0;
  23.   }
  24.   void lcd12864_init()        //初始化
  25.   {
  26.    lcd12864_write_com(0xc0); //行的初始化地址
  27.    lcd12864_write_com(0xb8);//页的初始化地址
  28.    lcd12864_write_com(0x40);//列的初始化地址
  29.    lcd12864_write_com(0x3f);//打开屏幕        ,关闭是3e
  30.   }
  31.   void clear_lcd12864()        //清屏
  32.   {
  33.    uchar i,j;
  34.    cs1=1;cs2=1;         //打开左右两屏,实物  注意:LCD12864实物是CS1=1;CS2=1为打开,
  35.    for(i=0;i<8;i++)          //共8页
  36.    {
  37.    lcd12864_write_com(0xb8+i);//页的初始化地址
  38.    lcd12864_write_com(0x40);//列的初始化地址
  39.    for(j=0;j<64;j++)  //共64列
  40.    {
  41.    lcd12864_write_date(0x00);
  42.    }
  43.    }
  44.   }
复制代码

12864显示程序:
lcd12864dis.c
  1. /***********大汉字数组,取模方式32X32*****************/
  2. uchar code tab[][128]={

  3. //好好学习天天向上
  4.   /***********0-好*****************/
  5. {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,
  6. 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,
  7. 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,
  8. 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*/
  9.    /***********1-好*****************/
  10. {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,
  11. 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,
  12. 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,
  13. 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*/
  14. /***********2-学*****************/
  15. {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,
  16. 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,
  17. 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,
  18. 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*/
  19.   /***********3-习*****************/
  20. {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,
  21. 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,
  22. 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,
  23. 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*/
  24. /***********4-天*****************/
  25. {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,
  26. 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,
  27. 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,
  28. 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*/
  29.   /***********5-天*****************/
  30. {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,
  31. 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,
  32. 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,
  33. 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*/
  34.   /***********6-向*****************/
  35. {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,
  36. 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,
  37. 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,
  38. 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*/
  39.   /***********7-上*****************/
  40. {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,
  41. 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,
  42. 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,
  43. 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*/



  44. };
  45. /***********标准汉字数组,取模方式16X16*****************/
  46. uchar code tab_biao[][32]={
  47. /*********0-----好***************/
  48. {0x00,0x10,0x10,0xF0,0x1F,0x10,0xF0,0x00,0x80,0x82,0x82,0xE2,0x92,0x8A,0x86,0x80,
  49. 0x00,0x40,0x22,0x15,0x08,0x16,0x61,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00},
  50. /*********1-----好***************/
  51. {0x00,0x10,0x10,0xF0,0x1F,0x10,0xF0,0x00,0x80,0x82,0x82,0xE2,0x92,0x8A,0x86,0x80,
  52. 0x00,0x40,0x22,0x15,0x08,0x16,0x61,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00},
  53. /*********2-----学***************/
  54. {0x00,0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,
  55. 0x00,0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x04,0x04},
  56. /*********3-----习***************/
  57. {0x00,0x00,0x02,0x02,0x02,0x12,0x22,0xC2,0x02,0x02,0x02,0x02,0x02,0xFE,0x00,0x00,
  58. 0x00,0x00,0x08,0x18,0x08,0x04,0x04,0x04,0x02,0x02,0x41,0x81,0x40,0x3F,0x00,0x00},
  59. /*********4-----“:”***************/
  60. {0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  61. 0x00,0x00,0x00,0x00,0x7B,0x7B,0x7B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
  62.   /*********5-----心形***************/
  63. {0x00,0xE0,0x10,0x10,0x10,0x30,0x40,0x80,0x80,0x40,0x20,0x10,0x10,0x10,0xF0,0x00,
  64. 0x00,0x03,0x04,0x08,0x10,0x20,0x20,0x40,0x40,0x20,0x20,0x10,0x08,0x04,0x03,0x00},


  65. };

  66.   /*********小数字数组:半列显示,取模方式16X8***************/
  67. uchar code tab_banlie[][16]={

  68. /*********0***************/
  69. {0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
  70. 0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00},
  71. /*********1***************/
  72. {0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,
  73. 0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00},
  74. /*********2***************/
  75. {0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,
  76. 0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00},
  77. /*********3***************/
  78.   {0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,
  79. 0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00},
  80.         /*********4***************/
  81. {0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,
  82. 0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00},
  83.    /*********5***************/
  84. {0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,
  85. 0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00},
  86.         /*********6***************/
  87.    {0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,
  88. 0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00},
  89.   /*********7***************/
  90.   {0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,
  91. 0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00},
  92.         /*********8***************/
  93.    {0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,
  94. 0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00},
  95.         /*********9***************/
  96.    {0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
  97. 0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00},
  98.    /*********10--Q***************/
  99.   {0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,
  100. 0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00},

  101. };

  102.   /***********大汉字显示函数************************/
  103. void hanzi(uchar ye,uchar lie,uchar *shuzhu)        //定义任意页、任意列、任意数组(*表示指针类型)
  104. {
  105.   uchar i,j;
  106.   for(i=0;i<4;i++)        //4页
  107.   {
  108.   lcd12864_write_com(0xb8+ye+i);//页的初始化地址
  109.    lcd12864_write_com(0x40+lie);//列的初始化地址
  110.    for(j=0;j<32;j++)        //这里要显示大汉字,取模为32X32  
  111.    {
  112.    lcd12864_write_date(shuzhu[i*32+j]);
  113.    }
  114.   }
  115. }
  116.         /***********标准汉字显示函数************************/
  117. void hanzi2(uchar ye,uchar lie,uchar *shuzhu)        //定义任意页、任意列、任意数组(*表示指针类型)
  118. {
  119.   uchar i,j;
  120.   for(i=0;i<2;i++)        //2页
  121.   {
  122.   lcd12864_write_com(0xb8+ye+i);//页的初始化地址
  123.    lcd12864_write_com(0x40+lie);//列的初始化地址
  124.    for(j=0;j<16;j++)        //这里要显示标准汉字,取模为16X16  
  125.    {
  126.    lcd12864_write_date(shuzhu[i*16+j]);
  127.    }
  128.   }
  129. }
  130.            /***********小数字显示函数************************/
  131.   void shuzi2(uchar ye,uchar lie,uchar *shuzhu)        //定义任意页、任意列、任意数组(*表示指针类型)
  132. {
  133.   uchar i,j;
  134.   for(i=0;i<2;i++)        //2页
  135.   {
  136.   lcd12864_write_com(0xb8+ye+i);//页的初始化地址
  137.    lcd12864_write_com(0x40+lie);//列的初始化地址
  138.    for(j=0;j<8;j++)        //数字取半模,这里要改为8
  139.    {
  140.    lcd12864_write_date(shuzhu[i*8+j]);
  141.    }
  142.   }
  143. }
  144. void lcd12864_dis() //汉字显示函数
  145. {
  146. /*******显示第一行***********/

  147. cs1=1;cs2=0;//打开左半屏 ,实物

  148. shuzi2(0,0,tab_banlie[10]);// Q
  149. shuzi2(0,8,tab_banlie[10]);// Q
  150. hanzi2(0,16,tab_biao[4]); //":"
  151. shuzi2(0,32,tab_banlie[1]);// 1
  152. shuzi2(0,40,tab_banlie[2]);// 2
  153. shuzi2(0,48,tab_banlie[3]);// 3
  154. shuzi2(0,56,tab_banlie[4]);// 4

  155. cs1=0;cs2=1;//打开右半屏 ,实物

  156. shuzi2(0,0,tab_banlie[5]);// 5
  157. shuzi2(0,8,tab_banlie[6]);// 6
  158. shuzi2(0,16,tab_banlie[7]);// 7
  159. shuzi2(0,24,tab_banlie[8]);// 8
  160. shuzi2(0,32,tab_banlie[9]);// 9

  161.    /*******显示第二行(标准汉字)***********/

  162. cs1=1;cs2=0;//打开左半屏 ,实物

  163. hanzi2(2,0,tab_biao[0]); //好
  164. hanzi2(2,16,tab_biao[1]); //好
  165. hanzi2(2,32,tab_biao[2]);        //学
  166. hanzi2(2,48,tab_biao[3]); //习

  167. cs1=0;cs2=1;//打开右半屏 ,实物
  168. hanzi2(2,32,tab_biao[5]);        // 心



  169. /*******显示第三行(大汉字)***********/

  170. cs1=1;cs2=0;//打开左半屏 ,实物
  171. hanzi(4,0,tab[4]); //天
  172. hanzi(4,32,tab[5]); //天

  173. cs1=0;cs2=1;//打开右半屏 ,实物
  174. hanzi(4,0,tab[6]); //向
  175. hanzi(4,32,tab[7]); //上

  176. }
复制代码

0.png

全部资料51hei下载地址:
无字库LCD12864液晶同时显示大小汉字含全部资料.rar (7.27 MB, 下载次数: 237)

评分

参与人数 2黑币 +58 收起 理由
stkh + 8 很给力!
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

ID:403645 发表于 2018-9-28 16:52 | 显示全部楼层
大佬能分享一下取模软件吗
回复

使用道具 举报

ID:307643 发表于 2018-9-28 17:04 | 显示全部楼层
试试看效果
回复

使用道具 举报

ID:467921 发表于 2019-4-14 11:13 | 显示全部楼层
你好 请问4号引脚是D/I是程序上的RS吧
回复

使用道具 举报

ID:461428 发表于 2019-5-4 17:08 来自手机 | 显示全部楼层
这个不错。。学习了
回复

使用道具 举报

ID:553778 发表于 2019-6-6 14:43 | 显示全部楼层
谢谢,我收获了很多,知道该如何解决我遇到的问题了
回复

使用道具 举报

ID:74784 发表于 2019-10-5 18:23 | 显示全部楼层
出给我几个行不?
回复

使用道具 举报

ID:584814 发表于 2019-10-6 10:19 来自手机 | 显示全部楼层
这个很好,受益匪浅。
回复

使用道具 举报

ID:243267 发表于 2019-12-24 17:45 来自手机 | 显示全部楼层
我也是用无字库的12864液晶,为什么最多只能显示两个字模的汉字?是单片机内存不够吗?
回复

使用道具 举报

ID:31133 发表于 2020-4-11 17:43 | 显示全部楼层
这个资料不错,正需要
回复

使用道具 举报

ID:102939 发表于 2020-9-21 08:51 | 显示全部楼层
还有12864吗?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表