zoukankan      html  css  js  c++  java
  • ESP8266驱动SSD1306 ESP8266 for Arduino(NodeMCU U8G2库)

    材料:

     - NodeMCU

     - SSD1306 128*64 I2C接口

    接线:

    Arduino IDE,安装库:  "esp8266 by ESP8266 Community 2.7.4"(开发板管理) 和 "U8g2"(库)

    选择开发板: NodeMCU 1.0 (ESP-12E Module)

    Debug port: Serial1

    代码样例:

    #include <Arduino.h>
    #include <U8g2lib.h>
    
    #ifdef U8X8_HAVE_HW_SPI
    #include <SPI.h>
    #endif
    #ifdef U8X8_HAVE_HW_I2C
    #include <Wire.h>
    #endif
    
    U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ D5, /* data=*/ D6);   // ESP32 Thing, HW I2C with pin remapping
    
    
    void setup(void) {
      u8g2.begin();
    }
    
    void loop(void) {
      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(1000);  
    }

  • 相关阅读:
    R语言中的logical(0)和numeric(0)以及赋值问题
    创建hadoop用户
    虚拟机安装
    spark1-MapReduce
    arcgis1-shp转成mdb
    Actor-配置Maven
    scala6-单词计数(map(),flatMap())
    scala5-数组
    scala4-函数
    scala3-for循环
  • 原文地址:https://www.cnblogs.com/visionsl/p/14884896.html
Copyright © 2011-2022 走看看