#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Define the screen dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
// Create an OLED display object
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
// Initialize serial for debugging
Serial.begin(9600);
delay(1000); // Wait for serial to start
// Initialize the display with the I2C address (0x3C is common)
if (!display.begin(SSD1306_I2C, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Loop forever if initialization fails
}
// Clear the display buffer
display.clearDisplay();
// Set text size and color
display.setTextSize(1); // 1 = small text, 2 = medium, etc.
display.setTextColor(SSD1306_WHITE);
// Set cursor position
display.setCursor(0, 0);
// Print "Hello, World!" to the buffer
display.println(F("Hello, World!"));
// Display buffer content
display.display();
}
void loop() {
// Nothing to do here
}