Monday, April 18, 2016

Hello World NodeMCU (ESP8266) + 128x64 I2C OLED, using Adafruit SSD1306 library

Minimum "Hello World" run on NodeMCU (ESP8266) + 128x64 I2C OLED:


To setup libraries for 128x64 I2C OLED, refer last post "NodeMCU (ESP8266) to display on 128x64 I2C OLED".

NodeMCU_OLED_helloworld.ino
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET LED_BUILTIN  //4
Adafruit_SSD1306 display(OLED_RESET);

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

  // Clear the buffer.
  display.clearDisplay();
  display.display();

  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("Hello from:");
  display.println("http://arduino-er.blogspot.com/");
  display.display();

}

void loop() {
  // put your main code here, to run repeatedly:

}

No comments:

Post a Comment