ESP8266在Ardruino下點亮I2C的OLED屏

先説背景:

1.ESP8266開發(fā)板一塊
2.燒nodemcu鏡像
3.Ardruino下,設(shè)置好開發(fā)板是 nodeMCU1.0( ESP-12E)
4.開始寫軟件
5.下載

#include <U8g2lib.h>
#include <U8x8lib.h>

U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ D1, /* data=*/ D2, /* reset=*/ U8X8_PIN_NONE);   // 此處 D1 D2是對應(yīng)焊接的腳針

void setup() {
  // put your setup code here, to run once:
  u8g2.begin();
  u8g2.enableUTF8Print();
}

void loop() {
  // put your main code here, to run repeatedly:
  u8g2.clearBuffer();                    // clear the internal memory
  u8g2.setFont(u8g2_font_ncenB08_tr);    // choose a suitable font
  u8g2.drawStr(0,10,"Hello World!");    // write something to the internal memory
  u8g2.sendBuffer();                    // transfer internal memory to the display
  delay(2000); 

  u8g2.setFont(u8g2_font_unifont_t_chinese2);  // use chinese2
  u8g2.setFontDirection(0);
  u8g2.clearBuffer();
  u8g2.setCursor(0, 15);
  u8g2.print("你好世界");
  u8g2.setCursor(0, 30);
  u8g2.print("中文字");        // Chinese "Hello World"   
  u8g2.sendBuffer();
  delay(2000); 
  
}

然后顯示效果如下


image.png

結(jié)束

點個贊再走唄。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容