IIC_OLED12864模块__SKU___ - jimaobian/DFRobotWikiCn GitHub Wiki

概述

OLED12864模块是一款无需背光源自发光,像素个数为128*64点阵显示模块。显示颜色有蓝色、黄蓝两种,

显示尺寸0.96寸,驱动IC:SSD1306,该模块通过IIC接口与控制器通信。

Arduino平台可用,Gadgeteer平台可用。

性能描述

  • 工作电压:3.3V
  • 像素个数:128列 × 64行
  • 显示颜色:蓝色、黄蓝
  • 接口方式:IIC
  • 工作温度:-30℃~+70℃
  • 显示尺寸:21.744 × 10.864(mm)
  • 模块尺寸:42 × 32(mm)
  • 模块重量:

引脚定义

图片

Arduino平台应用

例子程序

  • 主程序

#include <Wire.h> #include "image.h" int UG2864Address = 0x3C;//OLED UG2864器件7位地址 //SDA-AD4,SCL-AD5(Gadgeteer socket:P8,P9) //端口设置 int RES = 6;//Gadgeteer socket P6 int DC = 7;//Gadgeteer socket P3 //写命令 void Writec(unsigned char COM) {     Wire.beginTransmission(UG2864Address);     Wire.send(0x00);     Wire.send(COM);     Wire.endTransmission(); } //写数据 void Writed(unsigned char DATA) {     Wire.beginTransmission(UG2864Address);     Wire.send(0x40);     Wire.send(DATA);     Wire.endTransmission(); } //OLED UG2864初始化 void SSD1306() {     Writec(0XAE);//display off     Writec(0X00);//set lower column address     Writec(0X10);//set higher column address     Writec(0X40);//set display start line     Writec(0XB0);//set page address     Writec(0X81);//set contract control     Writec(0XCF);// VCC Generated by Internal DC/DC Circuit     Writec(0XA1);//set segment remap  column address 127 is mapped to SEG0     Writec(0XA6);//normal / reverse   normal display     Writec(0XA8);//multiplex ratio     Writec(0X3F);//1/64     Writec(0XC8);//Com scan direction remapped mode. Scan from COM[N-1] to COM0     Writec(0XD3);//set display offset     Writec(0X00);     Writec(0XD5);//set osc division     Writec(0X80);     Writec(0XD9);//set pre-charge period     Writec(0X11);     Writec(0XDa);//set COM pins     Writec(0X12);     Writec(0X8d);/*set charge pump enable*/     Writec(0X14);     Writec(0Xdb);//Set VcomH     Writec(0X20);     Writec(0XAF);//display ON } //填充函数 void fill(unsigned char dat) {     unsigned char i,j;     Writec(0x00);//set lower column address     Writec(0x10);//set higher column address     Writec(0xB0);//set page address     for(j=0;j<8;j++)     {         Writec(0xB0+j);//set page address         Writec(0x00);//set lower column address         Writec(0x10);//set higher column address         for(i=0;i<128;i++)         {              Writed(dat);          }     } } //显示 void show() {     unsigned char x,y;     unsigned int j=0;     Writec(0x00);//set lower column address     Writec(0x10);//set higher column address     for(y=0;y<8;y++)     {           Writec(0xB0+y);//set page address           Writec(0x00);//set lower column address           Writec(0x10);//set higher column address           for(x=0;x<128;x++)           Writed(show2[j++]);     } } void setup() {     //端口模式设置      pinMode(RES,OUTPUT);//RES     pinMode(DC,OUTPUT);//D/C#     //SAO=0     digitalWrite(DC,LOW);     //IIC初始化      Wire.begin(); } void loop() {      //复位       digitalWrite(RES,HIGH);   delay(1000);      digitalWrite(RES,LOW);    delay(1000);      digitalWrite(RES,HIGH);   delay(1000);      //初始化       SSD1306();      fill(0xff);//点亮屏幕       delay(100);      fill(0x00);//清屏       delay(100);      while(1)      {         show();      } }

  • image.h文件

unsigned char  show1[] = { 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x00,0x00,0x00,0x82,0xFF,0x80,0x00,0x00, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x00,0x00,0xC6,0xA1,0x91,0x89,0x86,0x00, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x00,0x00,0x00,0x82,0xFF,0x80,0x00,0x00,0x00,0x00,0xC6,0xA1,0x91,0x89,0x86,0x00, 0x00,0x00,0x42,0x81,0x89,0x89,0x76,0x00,0x00,0x00,0x10,0x2C,0x22,0xFF,0xA0,0x00, 0x00,0x00,0x4F,0x89,0x89,0x89,0x71,0x00,0x00,0x00,0x42,0x81,0x89,0x89,0x76,0x00, 0x00,0x00,0x03,0x01,0xF9,0x07,0x01,0x00,0x00,0x00,0x76,0x89,0x89,0x89,0x76,0x00, 0x00,0x00,0x0E,0xD1,0x91,0x91,0x7E,0x00,0x00,0x00,0x7E,0x81,0x81,0x81,0x7E,0x00, 0x00,0x00,0x00,0x82,0xFF,0x80,0x00,0x00,0x00,0x00,0xC6,0xA1,0x91,0x89,0x86,0x00, 0x00,0x00,0x42,0x81,0x89,0x89,0x76,0x00,0x00,0x00,0x10,0x2C,0x22,0xFF,0xA0,0x00, 0x00,0x00,0x4F,0x89,0x89,0x89,0x71,0x00,0x00,0x00,0x7E,0x89,0x89,0x8B,0x70,0x00, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x00,0x00,0x10,0x2C,0x22,0xFF,0xA0,0x00, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, }; unsigned char  show2[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//*1 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x08,0xF8,0x88,0x88,0xE8,0x08,0x00,0x00, //DF上半 0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,//Ro 0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,//bo 0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//t 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//*2 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//DF下半 0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//Ro 0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//bo 0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//t 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//*3 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,//*4 0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,// 0x80,0x88,0xF8,0x00,0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x80,0x80,0x80,0x00,// 0x80,0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x08,0xF8,0x00,0x80,//ro 0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x80,0x80,0xE0,//b0 0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,//t.c 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,//om 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//. 0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//*1 0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,0x00,0xc0,0xc0,0x00,0x00,0x0E,0x11,0x20,// 0x20,0x10,0x3F,0x20,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,0x20,0x20,0x3F,0x21,// 0x20,0x00,0x01,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,0x00,0x3F,0x11,0x20,//ro 0x20,0x11,0x0E,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,0x00,0x00,0x00,0x1F,//bo 0x20,0x20,0x00,0x00,0x00,0xc0,0xc0,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//t.c 0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//om 0x00,0x00,0xc0,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//*2 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//*3 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,//cn 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//*4 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//cn 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// };

下载上述程序到控制器,在这里选择Arduino 328作为控制器举例说明

硬件连接

选用杜邦线(公母头)作为连接线,将模块与328板子连接起来

杜邦线一端插在模块排针,另一端插在328板子,线序如下:

模块————328板子

3.3————3V3

G————GND

RST————6(数字IO,6脚)

SDA————4(模拟IO,4脚)

SCL————5(模拟IO,5脚)

DC————7(数字IO,7脚)

将S1开关拨到ON,即给SDA、SCL加上拉电阻

外接电源给328板子供电或者直接用USB给328板子供电,上电后即可看到模块显示如下字符:

DFRobot

www.dfrobot.com.cn

图片

Gadgeteer平台应用

例子程序

硬件连接

⚠️ **GitHub.com Fallback** ⚠️