0.96寸OLED 接线 | 您所在的位置:网站首页 › 彩色显示屏的接线图怎么看 › 0.96寸OLED 接线 |
这个显示器模块出厂默认的是SPI模式,所以只能用spi模式显示,如果想改成IIC的,需要焊接R1 R4 R8。 给Arduino写程序时一定要连着RESET,否则可能不显示。 接线如下 GND -------- 地 VDD -------- 3.3或者5v SCK -------- 13 SDA -------- 11 RES -------- RESET DC -------- 9 CS -------- 10
下面是Hello World 的例子
#include "U8glib.h" /*SPI协议*/ U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 void setup() { if ( u8g.getMode() == U8G_MODE_R3G3B2 ) u8g.setColorIndex(255); // white else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) u8g.setColorIndex(3); // max intensity else if ( u8g.getMode() == U8G_MODE_BW ) u8g.setColorIndex(1); // pixel on // u8g.setFont(u8g_font_unifont); Serial.begin(9600); u8g.setFont(u8g_font_6x10); u8g.setFontRefHeightExtendedText(); u8g.setDefaultForegroundColor(); u8g.setFontPosTop(); } void loop() { u8g.firstPage(); do { u8g.drawStr(0,0,"hello world!"); } while( u8g.nextPage() ); delay(500); } 显示温湿度 #include "U8glib.h" /*SPI协议*/ U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 int n = 0; void setup() { if (u8g.getMode() == U8G_MODE_R3G3B2) u8g.setColorIndex(255); // white else if (u8g.getMode() == U8G_MODE_GRAY2BIT) u8g.setColorIndex(3); // max intensity else if (u8g.getMode() == U8G_MODE_BW) u8g.setColorIndex(1); // pixel on // u8g.setFont(u8g_font_unifont); Serial.begin(9600); u8g.setFont(u8g_font_6x10); u8g.setFontRefHeightExtendedText(); u8g.setDefaultForegroundColor(); u8g.setFontPosTop(); } void draw(void) { u8g.setFont(u8g_font_8x13); //使用8x13大小的字符 u8g.setPrintPos(0, 20); // 对应 x,y 轴值 u8g.print("HUMI(%) :"); u8g.setPrintPos(73, 20); u8g.print("50"); u8g.setPrintPos(0, 40); u8g.print("TEMP(oC):"); u8g.setPrintPos(73, 40); u8g.print("23"); } void loop() { u8g.firstPage(); do { draw(); } while ( u8g.nextPage ()); delay(1000); n = n + 1; }
|
今日新闻 |
推荐新闻 |
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 |