Untitled

 avatar
unknown
plain_text
9 days ago
826 B
4
Indexable
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// OLED Display width and height
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

// Initialize OLED display (I2C: SDA = GPIO 21, SCL = GPIO 22)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
    Serial.begin(115200);

    // Start OLED display
    if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { 
        Serial.println("OLED initialization failed!");
        while (1);
    }

    // Clear display buffer
    display.clearDisplay();
    
    // Set text properties
    display.setTextSize(2);            
    display.setTextColor(WHITE);      
    display.setCursor(10, 20);         
    display.println("Hello, ESP32!"); 

    // Display text
    display.display();
}

void loop() {
  // Nothing to do here
}
Editor is loading...
Leave a Comment