#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Define the OLED display dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
// Create an object of the OLED display (using I2C)
// Using the I2C address 0x3C for the OLED display
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
// Initialize the OLED display with the correct I2C address (0x3C)
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Hang here if initialization fails
}
display.display(); // Show initial display
delay(2000); // Wait for 2 seconds
// Clear the display
display.clearDisplay();
// Set text size and color
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
// Display "Hello World"
display.print(F("Hello World!"));
// Show the content
display.display();
}
void loop() {
// Nothing to do here, the message is displayed once
}