#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
// Initialize with the I2C address 0x3C (some displays may have a different address)
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;);
}
// Clear the display buffer
display.clearDisplay();
// Set text size, color, and position
display.setTextSize(1); // 1: Smallest, 2: Medium, 3: Largest
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
// Print the text
display.println(F("Hello, OLED!"));
// Display the content
display.display();
}
void loop() {
// No need for anything in the loop for this example
}