#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED width in pixels.
#define SCREEN_HEIGHT 64 // OLED height (pixels)
#define OLED_RESET -1 // reset pin (-1 means share Arduino reset pin)
#define I2C_ADDRESS 0x3C // Common I2C address (0x3C or 0x3D)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
Wire.begin(SDA, SCL); // Initialize I2C, default pins of XIAO ESP32S3 are D4(SDA)/D5(SCL).
// Initialize OLED display
if(!display.begin(SSD1306_SWITCHCAPVCC, I2C_ADDRESS)) {
Serial.println(F("SSD1306 failed to allocate"));
for(;;); // stuck loop
}
display.clearDisplay(); // clear display cache
display.setTextSize(1); // set the text size (1:1 ratio)
display.setTextColor(SSD1306_WHITE); // draw white text
display.setCursor(0, 0); // start coordinate (0,0)
display.println("hello, fab academy"); // draw white text.
display.println("hello, fab academy");
display.display(); // output the cached content to the screen
}
void loop() {
// Empty loop, only need to display once
}
esp:D0
esp:D1
esp:D2
esp:D3
esp:D4
esp:D5
esp:D6
esp:D7
esp:D8
esp:D9
esp:D10
esp:3V3
esp:GND
esp:5V
oled1:GND
oled1:VCC
oled1:SCL
oled1:SDA