#include <Wire.h>
//#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
// create a display object called "oled"
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
Serial.begin(9600);
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
// if starting the display doesn't work don't proceed
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // address 0x3C for 128x64
Serial.println(F("SSD1306 allocation failed"));
for (;;); // don't proceed, loop forever
}
oled.setTextSize(2); // 2:1 pixel scale
// Draw white text on black background
oled.setTextColor(SSD1306_WHITE, SSD1306_WHITE);
// Show initial display buffer contents on the screen --
// the library initializes this with an Adafruit splash screen.
oled.display();
delay(2000); // Pause for 2 seconds
// Clear the buffer
oled.clearDisplay();
oled.setCursor(30, 10); // x, y cursor position
oled.print("Hello");
oled.setCursor(30, 30); // x, y cursor position
oled.print("world!");
oled.display(); // always need to use the display method after drawing
}
void loop() {
// nothing to loop about
}