/* Week 10: Output Devices Project: I2C OLED Display (SSD1306) Microcontroller: XIAO ESP32C3 */ #include #include #include // Screen dimensions in pixels #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) // The reset pin is not used on most I2C OLED modules #define OLED_RESET -1 #define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3C is common Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); void setup() { Serial.begin(115200); // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1306 allocation failed")); for(;;); // Don't proceed, loop forever } // Clear the buffer display.clearDisplay(); // Set text color and size display.setTextSize(1); display.setTextColor(SSD1306_WHITE); // Display Hello Message display.setCursor(0, 0); display.println(F("XIAO ESP32C3")); display.setCursor(0, 20); display.setTextSize(2); display.println(F("Success!")); display.setTextSize(1); display.setCursor(0, 50); display.println(F("Week 10: Output")); // Actually draw everything to the screen display.display(); } void loop() { // Static display, no loop code needed }