OLED Display
0.96-inch I2C OLED screen powered by the Arduino.
- Intermediate
- Displays
- 2 parts
Opens in your browser with the parts, wiring and code already in place. Press Run to watch it work, then change anything you like.
How it works
An SSD1306 OLED is a small screen, here 128 by 64 pixels, that makes its own light. It talks over I2C, a two-wire bus: SDA (data) on A4 and SCL (clock) on A5 on an Uno, plus power (3.3 V here) and ground. Several I2C devices can share those two wires because each answers to its own address; this screen is at 0x3C.
The sketch creates a display object with its size, display(128, 64, &Wire, -1), and starts it with display.begin(SSD1306_SWITCHCAPVCC, 0x3C). Drawing happens in a memory buffer: clearDisplay() empties it, setTextSize() and setCursor() choose how and where text goes, println() writes “CYTHEIA” and “OLED via I2C”, and display.display() finally sends the buffer to the screen. Nothing appears until that last call.
Parts
- Arduino Uno
- OLED Display
Wiring
- Arduino Uno 3.3V → OLED Display VCC
- Arduino Uno GND → OLED Display GND
- Arduino Uno A5 → OLED Display SCL
- Arduino Uno A4 → OLED Display SDA
Arduino code
// OLED Display (SSD1306 via I2C)
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// 128 x 64 pixels, talking over the I2C pins A4 (SDA) and A5 (SCL)
Adafruit_SSD1306 display(128, 64, &Wire, -1);
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println("CYTHEIA");
display.setTextSize(1);
display.println("OLED via I2C");
display.display();
Serial.println("OLED ready");
}
void loop() {
delay(1000);
}
Try changing it
- Change the headline: edit the text in display.println("CYTHEIA").
- Show something live: in loop(), replace delay(1000) with code that calls display.clearDisplay(), prints millis() / 1000, and ends with display.display().