查看: 2265|回复: 0

Stduino 传感器拓展(三)LCD12864

[复制链接]

53

主题

55

帖子

431

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
431
发表于 2020-8-7 15:58:37 | 显示全部楼层 |阅读模式
关键词:51stm32arduinostduino单片机stduino UNO&NanoLCD12864
说明:
带中文字库的LCD128X64是一种具有4/8位并行、2线或3线串行多种接口方式,内部含有国标一级、二级简体中文字库的点阵图形液晶显示模块其显示分辨率为128×64,内置819216*16点汉字,和12816*8ASCII字符集。利用该模块灵活的接口方式和简单、方便的操作指令,可构成全中文人机交互图形界面。可以显示8×416×16点阵的汉字。
LCD12864有多种接线方式,依据数据传输的方式可以分为8位并口、4位并口以及串口接线三种方式。串口接线只需要接一根数据线,节约了端口,因此,我们采用串口接线的方式。
实验目的:
在本例中,我们将利用LCD12864模块输出特定字符,以及让LCD显示图片。
器材:
Stduino UNO/Nano;杜邦线;LCD12864
电路连接:
A03-LCD12864.png

示例一:输出特定字符代码:
  1. #include <Arduino.h>
  2. #include <LCD12864.h>

  3. Lcd12864 lcd12864;
  4. void setup()
  5. {
  6.   // put your setup code here, to run once:

  7.     lcd12864.initial(A2,A1,A0,9);//  EN,RW,RS,PSB
  8.     lcd12864.clean();//清屏
  9.     delay(20);
  10.    
  11. }



  12. void loop()
  13. {
  14.   // put your main code here, to run repeatedly:
  15.     lcd12864.clean();//清屏
  16.    
  17.     lcd12864.ShowString(0,2,"思特诺");//从第0行第2列开始 输出"思特诺"内容
  18.     lcd12864.ShowString(1,2,"Stduino");//从第1行第2列开始 输出"Stduino"内容
  19.     lcd12864.ShowString(3,1,"创建时间:    年");//从第3行第1列开始输出"创建时间:    年"内容
  20.     lcd12864.ShowInt(3,6,2020);//从第3行第6列开始 输出2020内容
  21.     lcd12864.ShowDouble(2,1,123.43);//从第2行第1列开始 输出123.43内容
  22.    
  23.     delay(1000);//延时1000ms

  24. }
复制代码



示例二:显示128×64像素大小的图画。
首先我们需要利用Krita或者其他绘图软件制作一幅128×64大小的黑白bmp格式的图片。接下来,将其导入到取字模软件,获得Stduino IDE可识别的每一像素点的信息。随后利用DrawFullScreen()方法,将像素点的信息传递给LCD上的每一位地址,即可绘制全屏的像素图。

第一步:在Krita中新建128×64大小的文档,并绘制像素图,保存为BMP文件:
A03-LCD12864-02新建文档.png
因为今年有千年一遇的新智彗星访问地球,因此画了一幅彗星的图片,嘿嘿,算作补上没有看到的遗憾吧。
A03-LCD12864-03图片说明.png

A03-LCD12864-04保存.png
第二步,利用取字模软件,将BMP图转化为像素信息:
参数确认:选择C语言以及输出大小(128×64),点击参数确认;
A03-LCD12864-05取字模.png
载入图片:点击载入图片,选择刚才你制作好的图片,上部黑白取反依据需要提前选择好。
A03-LCD12864-06取字模设置.png

数据保存:载入图片没有问题之后,选择“数据保存”,信息以保存在新的文件当中。
A03-LCD12864-07取字模信息保存.png
利用Hbuider或者Notepad++等文本编译器打开保存的文件,大括号内的数据就是我们需要的内容:
A03-LCD12864-08取字模HBUIDER.png
第三步:编写代码。
把前面的数据复制到一个无符号字符数组中,再利用DrawFullScreen()方法处理即可。
代码如下:
  1. #include <Arduino.h>
  2. #include <LCD12864.h>

  3. Lcd12864 lcd12864;
  4. unsigned char newWise[]={  //你的图片的数据
  5.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  6.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  7.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  8.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  9.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  10.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  11.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  12.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  13.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  14.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  15.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  16.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  17.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18.       0x00,0x00,0x00,0x00,0x19,0x87,0xBC,0x00,
  19.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  20.       0x00,0x00,0x00,0x01,0x18,0x10,0x00,0x00,
  21.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  22.       0x00,0x00,0x00,0x60,0xC2,0x40,0x00,0x00,
  23.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  24.       0x00,0x00,0x00,0x46,0x00,0x00,0x00,0x00,
  25.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  26.       0x00,0x00,0x29,0x08,0x00,0x00,0x00,0x00,
  27.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  28.       0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
  29.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  30.       0x00,0x08,0xB0,0x00,0x10,0x00,0x00,0x00,
  31.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  32.       0x00,0xDC,0x00,0xA4,0x25,0x40,0x00,0x00,
  33.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  34.       0x03,0x01,0x12,0x00,0x00,0x08,0x00,0x00,
  35.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  36.       0x3B,0x94,0x00,0x00,0x00,0x00,0x00,0x00,
  37.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  38.       0x41,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
  39.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,
  40.       0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  41.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6B,
  42.       0xC8,0x00,0x00,0x00,0x00,0x00,0x00,0x04,
  43.       0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x8F,
  44.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  45.       0x04,0x00,0x00,0x00,0x00,0x00,0x05,0x98,
  46.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  47.       0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xF8,
  48.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  49.       0x00,0x00,0x00,0x10,0x00,0x00,0xF7,0xF0,
  50.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  51.       0x00,0x00,0x00,0x00,0x00,0x01,0xFC,0xC0,
  52.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  53.       0x00,0x00,0x00,0x00,0x00,0x01,0xF3,0x00,
  54.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
  55.       0x00,0x00,0x00,0x00,0x00,0x03,0xFC,0x00,
  56.       0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
  57.       0x00,0x00,0x00,0x00,0x00,0x07,0xF8,0x00,
  58.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  59.       0x00,0x00,0x00,0x00,0x00,0x07,0xC0,0x00,
  60.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  61.       0x40,0x00,0x00,0x00,0x00,0x07,0x00,0x00,
  62.       0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,
  63.       0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,
  64.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  65.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  66.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
  67.       0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
  68.       0x00,0x00,0x00,0x00,0x40,0x00,0x02,0x00,
  69.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
  70.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  71.       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  72.       0x00,0x00,0x00,0x00,0x80,0x03,0x40,0x01,
  73.       0x40,0x40,0x03,0x00,0x00,0x00,0x00,0x00,
  74.       0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x10,
  75.       0x00,0x01,0x00,0x00,0x00,0x00,0x02,0x00,
  76.       0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,
  77.       0x00,0x40,0x00,0x01,0x00,0x80,0x00,0x00,
  78.       0x04,0x01,0x00,0x40,0xA3,0x80,0x06,0x18,
  79.       0x04,0x00,0x20,0x00,0x08,0x00,0x00,0x04,
  80.       0x00,0x96,0x00,0x20,0x80,0x10,0x80,0x04,
  81.       0x00,0x40,0x01,0x00,0x00,0x08,0x06,0x01,
  82.       0x40,0x00,0x08,0x00,0x00,0x00,0x84,0x00,
  83.       0x80,0x00,0x00,0x18,0x52,0x01,0x00,0x30,
  84.       0x01,0x00,0x60,0x29,0xB9,0xC0,0xC0,0x46,
  85.       0x90,0x00,0x00,0x40,0x00,0x02,0x80,0x02,
  86.       0x09,0x00,0x00,0x52,0x01,0x28,0x8C,0xFA,
  87.       0x40,0xA9,0x08,0x20,0x34,0x00,0x0E,0xE0,
  88.       0x43,0x94,0x73,0x62,0x0D,0xDC,0x0C,0x15,
  89.       0x42,0x00,0x20,0x04,0x00,0x00,0x19,0xB7,
  90.       0x3D,0xE8,0x7F,0x9A,0xEB,0x36,0xF9,0xFC,
  91.       0x00,0x08,0x44,0x00,0x14,0x0C,0xD5,0x7B,
  92.       0xC3,0x99,0x78,0xEB,0x20,0x43,0xBB,0x1A,
  93.       0x14,0xA1,0x80,0x11,0x00,0x02,0x00,0x3F,
  94.       0x81,0x81,0xC2,0x3F,0xAF,0xEF,0x3E,0x18,
  95.       0x31,0x0C,0x88,0xD0,0x98,0xB0,0x40,0x3E,
  96.       0x4D,0xFD,0xE4,0x1F,0xDF,0x3F,0xD8,0x58,
  97.       0xAC,0x00,0x0B,0x01,0x6E,0x88,0x02,0x5C,
  98.       0xFE,0xF9,0xEC,0x0F,0x9F,0x9D,0x70,0x0F,
  99.       0xF2,0x10,0xE4,0x00,0x65,0x00,0x03,0x09,
  100.       0xFE,0x7F,0xC9,0x07,0xBF,0xC7,0xC0,0x47,
  101.       0xCB,0x0C,0x49,0xB4,0x48,0x30,0x01,0xE3,
  102.       0xF1,0x3F,0x89,0x03,0xFF,0xB3,0x80,0x77,
  103.       0xF2,0xED,0xEF,0x6E,0xC3,0xF0,0x0D,0xF9,
  104.       0xC0,0x8E,0x02,0x10,0xFF,0xFF,0x01,0x3B,
  105.       0xE6,0x08,0x71,0xC3,0x00,0xC0,0x0C,0xF0,
  106.       0x00,0xE4,0x00,0x8F,0x1F,0xF8,0x01,0x39,
  107.       0x7E,0x0F,0x70,0x00,0x75,0x00,0x6E,0x62,
  108.       0x00,0x70,0x01,0xCF,0x0F,0xF0,0x03,0x3D,
  109.       0xFF,0xFF,0x4E,0x44,0x86,0x00,0xEF,0x00,
  110.       0x18,0x60,0x03,0xC7,0xE3,0xE0,0x03,0x3E,
  111.       0xE7,0xE8,0xC9,0xE6,0xFC,0x00,0xE7,0x00,
  112.       0x1C,0xA0,0x03,0xE3,0xF1,0x80,0x03,0xBE,
  113.       0x80,0xFB,0x7A,0xF2,0xF0,0x01,0xF8,0x00,
  114.       0x18,0x00,0x01,0xFB,0xF0,0x00,0x01,0x9F,
  115.       0x80,0x3F,0xBC,0xFF,0x80,0x03,0xF0,0x00,
  116.       0x38,0x60,0x01,0xC9,0x98,0x00,0x01,0xCF,
  117.       0x80,0x01,0x3F,0xE0,0x00,0x01,0xE0,0x00,
  118.       0x62,0x70,0x00,0xE7,0xF0,0x00,0x30,0xE7,
  119.       0x00,0x40,0x00,0x00,0x00,0x83,0x60,0x00,
  120.       0xF6,0x26,0x1C,0xD7,0x80,0x00,0x30,0xE7,
  121.       0x00,0x3F,0x10,0x00,0x00,0x00,0x00,0x09,
  122.       0xC7,0x72,0xCE,0x6B,0xE0,0x00,0x18,0x7F,
  123.       0x00,0x47,0xE0,0x00,0x00,0x00,0x00,0x13,
  124.       0x0F,0x04,0x81,0x65,0xF0,0x00,0x0C,0x7F,
  125.       0x00,0x53,0xF4,0x00,0x00,0x00,0x00,0x1E,
  126.       0x07,0x33,0x00,0xF4,0x60,0x00,0x0E,0x7F,
  127.       0x00,0x00,0x7D,0x80,0x00,0x00,0x00,0x3C,
  128.       0x07,0x3D,0x84,0x33,0x00,0x08,0x0E,0x3F,
  129.       0x01,0x00,0x3F,0xF0,0x00,0x08,0x02,0x1C,
  130.       0x47,0x1F,0x07,0x19,0x40,0x18,0x2E,0x3F,
  131.       0x00,0x00,0x07,0xE7,0x80,0x08,0x02,0x10,
  132.       0x44,0x1F,0x03,0xC0,0x00,0x10,0x26,0x3F
  133. };

  134. void setup()
  135. {
  136.   // put your setup code here, to run once:

  137.     lcd12864.initial(A2,A1,A0,9);
  138.     lcd12864.clean();
  139.     delay(20);
  140.    
  141. }



  142. void loop()
  143. {
  144.   // put your main code here, to run repeatedly:
  145.     lcd12864.clean();
  146.     lcd12864.DrawFullScreen(newWise);
  147.     delay(50000);

  148. }
复制代码

效果:
A03-LCD12864-09效果图.png


newWise.bmp
回复

使用道具 举报

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

本版积分规则

热门推荐

Stduino 零基础入门课程系列(五) 实验三:按键输入
Stduino 零基础入门课程系
Hello!各位同学大家好~上节课我们利用管脚输出高低电平信号,控制LED的亮灭,那么我
Stduino小白练习第六弹--按键控制串口通信
Stduino小白练习第六弹--
2020/01/08 星期三 作者:Astilbe 问题:我们如何通过按下按键来传输固定的信息给PC呢
37种传感器(二十九)MPU6050陀螺仪模块+Stduino Nano&UNO
37种传感器(二十九)MPU6
StduinoUno /纳米37种传感器(二十九)六轴 MPU陀螺仪模块关键词: 51 ; stm32 ; ar
stm32 最小系统 小蓝板 LED闪烁灯(三),无需刷Bootloader
stm32 最小系统 小蓝板 LE
关键词:stm32 小蓝板 STM32F103C8T6 Stduino IDE Stduino Nano LED闪烁灯 通过Stduin
Stduino IDE软件下载专区
Stduino IDE软件下载专区
Stduino IDE软件下载专区 Windows版:7月29号发布1.01, 现可
今天在文涛老大的帮助下我的stm32zet6终于把simlpefoc库跑起...
今天在文涛老大的帮助下我
[md]首先本身是刚刚从MDK转到arduino过来的新人,只因为要完开源的simplefoc,期间由
连接ADS1292模拟前端芯片,使用SPI库,导致串口不输出数据
连接ADS1292模拟前端芯片
[md]连接ADS1292模拟前端芯片,使用SPI库,导致串口不输出数据 ![QSJSBEZF83I8C907%$
©2001-2018  Stduino官网  Powered by©Discuz!   ( 皖ICP备17011998号 )
快速回复 返回顶部 返回列表