/*
* This ESP32 code is created by esp32io.com
*
* This ESP32 code is released in the public domain
*
* For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-oled
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED width, in pixels
#define SCREEN_HEIGHT 64 // OLED height, in pixels
#define SCREEN_ADDR 0x3C // I2C address of screen
// create an OLED display object connected to I2C
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
Serial.begin(115200);
// initialize OLED display with I2C
if (!oled.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDR)) {
Serial.println(F("failed to start SSD1306 OLED"));
while (1);
}
//delay(2000); // wait two seconds for initializing
oled.clearDisplay(); // clear display
oled.setTextSize(1); // set text size
oled.setTextColor(WHITE); // set text color
}
void loop() {
oled.clearDisplay(); // clear display
oled.setCursor(0, 10); // set position to display
oled.println("Hello, world!"); // set text
oled.display(); // display on OLED
delay(1000);
oled.clearDisplay(); // clear display
oled.setCursor(0, 10); // set position to display
oled.println("world, Hello!"); // set text
oled.display(); // display on OLED
delay(1000);
}