SPI LCD12864 模块 兼容Arduino

            <img alt="DFR0091.jpg" src="http://images.ncnynl.com/arduino/2016/400px-DFR0091.jpg" width="400" height="296" class="thumbimage" />  <img src="http://images.ncnynl.com/arduino/2016/magnify-clip.png" width="15" height="11" alt="" />

目录

1 概述
2 技术规格
3 引脚说明图
4 U8glib库的使用

4.1 1.接线图
4.2 2.显示字符

4.2.1 (1)接线图
4.2.2 (2)演示字符显示代码

4.3 3.显示图片

4.3.1 (1)图片转换
4.3.2 (2)接线
4.3.3 (3)演示显示图片代码

4.4 4.显示中文

4.4.1 (1)汉字转换
4.4.2 (2)接线图
4.4.3 (3)演示显示屏显示汉字“人”代码
4.4.4 (4)多个汉字显示代码注意事项
4.4.5 (5)多个汉字显示代码演示

4.5 5.部分代码解释

5 12864LCDSPI库函数的使用

5.1 1.12864LCDSPI接线方式
5.2 2.LCD12864RSPI显示字符

5.2.1 (1)接线
5.2.2 (2)演示显示字符代码

5.3 3.LCD12864RSPI显示汉字

5.3.1 (1)汉字解码方法
5.3.2 (2)连线图
5.3.3 (3)LCD12864RSPI 文字演示代码

5.4 4.LCD12864RSPI 显示图片

5.4.1 (1)图片转换
5.4.2 (2)连线图
5.4.3 (3)LCD12864RSPI的图片显示代码

5.5 4.部分代码解释

6 相关文档

概述
SPI LCD12864模块是一款基于12864液晶显示器开发的显示模块。考虑到LCD12864显示器在并行数据传输模式下的使用难度较高,驱动代码较为复杂,我们开发了这款SPI为接口的显示模块。
12864带汉字库图形点阵液晶显示模块,可显示8192个中文汉字(16X16点阵)、128个字符(8X16点阵)和图形显示(128X64点阵)。该模块具有并行和串行接口,背光控制(并行模式时使用),背光开关(串行模式使用),串行、并行模式开关切换功能,对比度调节电位器。
接口电路板隐藏于LCD背面,即美观又不影响安装。使用IDC6插座作为SPI串行接口,使用一个IDC6专用连接线即可插接到interface shield上实现串行控制,使用杜邦排线可连接到Arduino传感器扩展板上实现并行控制,可与Arduino控制器组成一个强劲的显示系统。

技术规格
电源电压:VDD4.5~5.5V(内置升压电路,无需负压)
控制器:ST7920
点阵个数:128列×64行
显示颜色:蓝底白字
可视角度:170度
LCD类型:STN
控制接口:4/8位数字并行驱动(LCD12864默认模式)和3位串行
LED背光:蓝色
软件功能:光标显示、画面移位、自定义字符、反白显示、睡眠模式等。
工作温度:-20℃~70℃
存储温度:-30℃~80℃
可通过连接Interface Shield使用Arduino直接驱动,也可根据引脚图使用杜邦线连接
模块尺寸:93×70×22mm
视域尺寸:73×39mm

引脚说明图
链接示意图
U8glib库的使用
1.接线图

"U8glib 接线" 引脚 接线

VSS

GND

VDD

5V

RS

模拟口A3

R/W

模拟口A2

E

模拟口A4

11.png
2.显示字符
(1)接线图
参考上面的接线图

(2)演示字符显示代码

#include "U8glib.h"
U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);
void draw(void) {
u8g.setFont(u8g_font_unifont);
u8g.drawStr( 0, 22, "Hello World!");
}

void setup(void) {

}

void loop(void) {
// picture loop
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
}

3.显示图片
(1)图片转换
第一:打开图形转换软件,设置模式为图形模式。

1156.png
第二:设置参数为C5I

1168.png
第三:打开要转换的图像,图像格式为位图(bmp)

1155.png
第四:然后点击生成字模即可,最后把生成的字模放入一个字符数组里面。

(2)接线
与上面接线的方式相同

(3)演示显示图片代码
该显示屏需用用到U8glib库文件,库及其相关资料

#include "U8glib.h"
U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);
const uint8_t rook_bitmap[] PROGMEM = {
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,
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,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,
0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,
0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xC0,
0x00,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0xFE,0x00,
0x00,0x0F,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0xF8,0x00,
0x00,0x03,0xF8,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x00,
0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x00,
0x00,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x00,
0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x00,
0x00,0x00,0x0F,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0x0F,0x1F,
0xEF,0xF0,0x07,0xC0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xF8,0x06,0x1B,
0x6D,0xB0,0x03,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xF0,0x06,0x3B,
0xED,0xA0,0x01,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xE0,0x06,0x31,
0xE9,0xE0,0x00,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xE0,0x06,0x31,
0xB9,0xA0,0x00,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xC0,0x06,0x79,
0xB9,0x98,0x00,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xC0,0x06,0xFB,
0x39,0xB0,0x00,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x80,0x0F,0xDF,
0x33,0xF0,0x00,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x00,
0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x3B,
0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x1B,
0x7F,0xB8,0x00,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x1A,
0x6D,0x90,0x00,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x1E,
0xEF,0x90,0x00,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x0E,
0xC7,0x90,0x00,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xE0,0x00,0x0C,
0xC7,0x90,0x00,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xE0,0x00,0x0C,
0xE7,0x90,0x00,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x0C,
0x6D,0xB0,0x01,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x0E,
0x7D,0xF0,0x03,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x0E,
0x00,0x00,0x07,0xC0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x00,
0x00,0x00,0x0F,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x00,
0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x00,
0x00,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x00,
0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0xF8,0x00,
0x00,0x03,0xF8,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0xFE,0x00,
0x00,0x0F,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xC0,
0x00,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,
0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,
0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0xFF,0xE0,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,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,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,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,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,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
void draw(void) {
// graphic commands to redraw the complete screen should be placed here
u8g.drawBitmapP( 0, 0, 16, 64, rook_bitmap);

}

void setup(void) {
}

void loop(void) {
// picture loop
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );

// rebuild the picture after some delay
delay(1000);
}
}

4.显示中文
(1)汉字转换
第一:打开PCtoLCD2002软件,选择模式为字符模式。

1156.png
第二:在文本框中输入字符“人”,设置参数为C5I,点击生成字模,最后把生成的字模放入一个字符数组里面。

1157.png
(2)接线图
与上面的接线图相同

(3)演示显示屏显示汉字“人”代码
显示汉字同样需要用到U8glib库函数,#库及其相关资料下载

#include "U8glib.h"//库函数
U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);
const uint8_t rook_bitmap[] PROGMEM = {
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
0x01,0x00,0x01,0x00,0x02,0x80,0x02,0x80,
0x04,0x40,0x04,0x40,0x08,0x20,0x08,0x20,
0x10,0x10,0x20,0x08,0x40,0x04,0x80,0x02,/"人",0/
};
void draw(void) {
// graphic commands to redraw the complete screen should be placed here
u8g.drawBitmapP( 0, 0, 2, 16, rook_bitmap);//第0行0列开始显示文字,生成的汉字“人”大小为16*16,所以后面的两个参数为(16/8,16).

}

void setup(void) {
}

void loop(void) {
// picture loop
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
// rebuild the picture after some delay
delay(1000);
}

(4)多个汉字显示代码注意事项 该取模软件,在生成字模时每个汉字会单独生成一个字模对应的数据,在显示多个汉字时,需要单独显示每个汉,即多次调用u8g.drawBitmapP( );这个函数。

(5)多个汉字显示代码演示

#include "U8glib.h"
U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);
const uint8_t rook_bitmap1[] PROGMEM = {
0x10,0x00,0x11,0xF0,0x11,0x10,0x11,0x10,
0xFD,0x10,0x11,0x10,0x31,0x10,0x39,0x10,
0x55,0x10,0x55,0x10,0x91,0x10,0x11,0x12,
0x11,0x12,0x12,0x12,0x12,0x0E,0x14,0x00,/"机",0/
};
const uint8_t rook_bitmap2[] PROGMEM = {
0x00,0x00,0x3E,0x7C,0x22,0x44,0x22,0x44,
0x3E,0x7C,0x01,0x20,0x01,0x10,0xFF,0xFE,
0x02,0x80,0x0C,0x60,0x30,0x18,0xC0,0x06,
0x3E,0x7C,0x22,0x44,0x22,0x44,0x3E,0x7C,/"器",1/
};
const uint8_t rook_bitmap3[] PROGMEM = {
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
0x01,0x00,0x01,0x00,0x02,0x80,0x02,0x80,
0x04,0x40,0x04,0x40,0x08,0x20,0x08,0x20,
0x10,0x10,0x20,0x08,0x40,0x04,0x80,0x02,/"人",2/
};
void draw(void) {
// graphic commands to redraw the complete screen should be placed here
u8g.drawBitmapP( 0, 0, 2, 16, rook_bitmap1);//0行0列显示“机”
u8g.drawBitmapP( 16, 0, 2, 16, rook_bitmap2);//0行16列显示“器”
u8g.drawBitmapP( 32, 0, 2, 16, rook_bitmap3);//0行32列显示“人”
}

void setup(void) {
}

void loop(void) {
// picture loop
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );

// rebuild the picture after some delay
delay(1000);
}
5.部分代码解释
u8g.drawStr( m, n, str);//m代表的是第m列,n代表的是第n行,str是要显示的字符串
u8g.drawBitmapP( m, n, x, y, str);//m代表的是第m列,n代表的是第n行,x代表的是生成字模点阵时的列数除以8,y代表的是点阵行数,str是要显示的字符串

例如显示汉字“人”u8g.drawBitmapP( 0, 0, 2, 16, rook_bitmap);//在生成字模时大小为16*16,那么x=16/2;y就是第二个16.

12864LCDSPI库函数的使用
1.12864LCDSPI接线方式
在下载程序时,还需要拨动以下开关。
1)Turn the BL_ON Switch to the "ON" side;
2)Turn the PBS_ON Switch to the "SPI" side

"SPI模式" 引脚 接线

VSS

GND

VDD

5V

RS

数字口8

R/W

数字口9

E

数字口3

SPI LCD 连线图
2.LCD12864RSPI显示字符
(1)接线
与上面12864SPI接线方式相同

(2)演示显示字符代码

#include "LCD12864RSPI.h"
#define AR_SIZE( a ) sizeof( a ) / sizeof( a[

void loop()
{
LCDA.CLEAR();//清屏
delay(100);

LCDA.DisplayString(2,1,show,AR_SIZE(show));;//第三行第二格开始,显示网址dfrobot.com/
delay(5000);
}

3.LCD12864RSPI显示汉字 (1)汉字解码方法 打开汉字解码软件,在待处理=字符串中输入要解码的汉字,点击转换即可,例如:

汉字解码图
(2)连线图
参考上面12864SPI的连线图

(3)LCD12864RSPI 文字演示代码

#include "LCD12864RSPI.h"
#define AR_SIZE( a ) sizeof( a ) / sizeof( a[

void loop()
{
LCDA.CLEAR();//清屏
delay(100);
LCDA.DisplayString(0,2,show,AR_SIZE(show));//第一行第三格开始,显示文智位机器人
delay(5000);
}

4.LCD12864RSPI 显示图片 (1)图片转换 第一:先打开photoshop,新建文档,大小为128*64,图片做好之后,保存格式为位图。

新建图片
第二:打开图片取模软件,先设置参数,选择c语言,输出大小X为128,Y为64。

参数设置
第三:载入制作好或者已有的位图图片。

打开图片
第四:保存数据,选择适当的位置,并给生成数据的文档命名。

保存数据
第五:打开保存生成数据的文档,并将其生成的字符数组复制到代码里面。

放入代码
(2)连线图
与上面12864SPI的连线图相同

(3)LCD12864RSPI的图片显示代码

#include "LCD12864RSPI.h"
#define AR_SIZE( a ) sizeof( a ) / sizeof( a[

void setup()
{
LCDA.Initialise(); // 屏幕初始化
delay(100);
}

void loop()
{

LCDA.DrawFullScreen(logo0);
delay(5000);
}

4.部分代码解释 LCDA.Initialise(); // 屏幕初始化 LCDA.CLEAR();//清屏 LCDA.DisplayString(m,n,str,length));//m代表的是行,n代表的是列,str代表的是要显示内容的名字,length是字符串的长度 LCDA.DrawFullScreen(logo0)//满屏显示内容

相关文档
U8glib库及其相关资料下载
12864库函数以及取模软件下载
老版本链接

Nextredirectltr.png购买SPI LCD12864 Module(Arduino兼容)

标签: Arduino传感器