文章目录
前言:
关于回家没带esp8266usb数据线,所以使用arduino和7针oled连接的小白。网上大多数的都是4针oled关于esp8266的显示教程,本人只有7针oled的。所以查了很多的资料,走了很多的弯路。
7针oled(spi协议)的引脚说明:
GND | 电源地 | GND | VCC | 电源正 | VCC | D0 | 时钟管脚 | 10 | D1 | 数据管脚 | 9 | RES | 复位管脚 | RES | DC | 数据和命令控制管脚 | 11 | CS | 片选管脚 | 12 |
关于中文的显示
#include "U8glib.h"
U8GLIB_SSD1306_128X64 u8g(10, 9, 12, 11); // SW SPI Com: SCL = 10, SDA = 9, CS = 12, DC = 11,RES=RESET
首先调用U8glib库程序,同时定义数据串口。
void loop(void) {
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
}
对主函数进行定义:分别调用显示开始和显示结束的函数u8g.firstPage(),u8g.nextPage(),这之间调用自己定义的draw()。
??
从取模软件进行获取字符串
void draw(void) {
u8g.drawXBMP( 0, 0,16, 16, str[0]);
u8g.drawXBMP( 16, 0,16, 16, str[1]);
u8g.drawXBMP( 32, 0,16, 16, str[2]);
u8g.drawXBMP( 48, 0,16, 16, str[3]);
}
u8g.drawXBMP
关于更多的u8glib库应用的链接:https://blog.csdn.net/sdlgq/article/details/88659636?ops_request_misc=&request_id=&biz_id=102&utm_term=arduino%20oled%20spi%20%20%E7%94%BB%E5%9B%BE&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~sobaiduweb~default-3-88659636.nonecase&spm=1018.2226.3001.4450?
完整的代码
#include "U8glib.h"
U8GLIB_SSD1306_128X64 u8g(10, 9, 12, 11); // SW SPI Com: SCL = 10, SDA = 9, CS = 12, DC = 11,RES=RESET
static const unsigned char str[4][32] PROGMEM={
{0x10,0x01,0x10,0x01,0x10,0x01,0x88,0x7F,0x88,0x40,0x4C,0x20,0x2C,0x04,0x0A,0x04,
0x89,0x14,0x88,0x24,0x48,0x24,0x48,0x44,0x28,0x44,0x08,0x04,0x08,0x05,0x08,0x02},/*"你",0*/
{0x08,0x00,0x08,0x3F,0x08,0x20,0x08,0x10,0x3F,0x08,0x24,0x04,0x24,0x04,0xA4,0x7F,
0x24,0x04,0x12,0x04,0x14,0x04,0x08,0x04,0x14,0x04,0x22,0x04,0x21,0x05,0x00,0x02},/*"好",1*/
{0x00,0x00,0xC0,0x3F,0x1E,0x08,0x92,0x08,0x92,0x08,0x92,0x08,0x52,0x08,0xD2,0x7F,
0x12,0x0C,0x12,0x0A,0x1E,0x09,0x92,0x08,0x40,0x08,0x20,0x08,0x00,0x0A,0x00,0x04},/*"呀",2*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00},/*":",3*/
/* (16 X 16 , 宋体 )*/
};
void draw(void) {
u8g.drawXBMP( 0, 0,16, 16, str[0]);
u8g.drawXBMP( 16, 0,16, 16, str[1]);
u8g.drawXBMP( 32, 0,16, 16, str[2]);
u8g.drawXBMP( 48, 0,16, 16, str[3]);
}
void setup(void) {
}
void loop(void) {
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
}
成品:
关于图片显示:
代码基本不变:
#include "U8glib.h"
//U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI
U8GLIB_SSD1306_128X64 u8g(10, 9, 12, 11); // SW SPI Com: SCL = 10, SDA = 9, CS = 12, DC = 11,RES=RESET
static const unsigned char str1[] 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,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,0xE0,0xFF,0xFF,0x7F,0xFC,0x03,0xF8,0x07,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00,
0x00,0xE0,0xFF,0xFF,0x7F,0xFC,0x03,0xF8,0x07,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00,
0x00,0xE0,0xFF,0xFF,0x7F,0xFC,0x03,0xF8,0x07,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00,
0x00,0xE0,0xFF,0xFF,0x7F,0xFC,0x03,0xF8,0x07,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00,
0x00,0xE0,0xFF,0xFF,0x7F,0xFC,0x03,0xF8,0x07,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00,
0x00,0xE0,0xFF,0xFF,0x7F,0xFC,0x03,0xF8,0x07,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00,
0x00,0xE0,0xFF,0xFF,0x7F,0xFC,0x03,0xF8,0x07,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00,
0x00,0xE0,0xFF,0xFF,0x7F,0xFC,0x03,0xF8,0x07,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00,
0x00,0xE0,0xFF,0xFF,0x7F,0xFC,0x03,0xF8,0x07,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00,
0x00,0xE0,0xFF,0xFF,0x7F,0xFC,0x03,0xF8,0x07,0xFF,0xFF,0xFF,0x01,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0x03,0xF8,0x07,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0x03,0xF8,0x07,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0x03,0xF8,0x07,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0x03,0xF8,0x07,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0x03,0xF8,0x07,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0x03,0xF8,0x07,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0x03,0xF8,0x07,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0x03,0xF8,0x07,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0x03,0xF8,0x07,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0xFF,0xFF,0x07,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0xFF,0xFF,0x07,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0xFF,0xFF,0x07,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0xFF,0xFF,0x07,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0xFF,0xFF,0x07,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x1F,0x00,0xFC,0xFF,0xFF,0x07,0x80,0xFF,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,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,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,
/* (16 X 16 , 宋体 )*/
};
void draw(void) {
u8g.drawXBMP( 0, 0,128, 64, str1);
}
void setup(void) {
}
void loop(void) {
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
}
成品
取模软件
我用的是??pctolcd2002 完美版:
这个软件画图的时候,每画一格就闪一下,非常的刺激眼睛。希望有大佬安利一下好用的取模软件
关于取模软件的设置
处女作就到此了,(狗头。jpg)
|