#include <Wire.h> // Include Wire library for I2C
#include <Adafruit_GFX.h> // Include Adafruit graphics library
#include <Adafruit_SSD1306.h> // Include Adafruit SSD1306 OLED library
#define SCREEN_WIDTH 128 // Define width of the screen
#define SCREEN_HEIGHT 64 // Define height of the screen
// Create an instance of the OLED display
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
// Initialize serial communication for debugging
Serial.begin(115200);
// Initialize the OLED display
if (!display.begin(SSD1306_I2C_ADDRESS, 0x3C)) { // Check if display is connected
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Don't proceed, loop forever
}
display.clearDisplay(); // Clear the buffer
display.setTextSize(1); // Set text size to 1
display.setTextColor(WHITE); // Set text color to white
display.setCursor(0, 0); // Set cursor position to top left corner
display.print("Hello, Wokwi!"); // Print message to display
display.display(); // Display all changes on the screen
}
void loop() {
}