Displays · Lesson
8 min read
OLED displays (SSD1306)
Graphics on a tiny screen with the Adafruit libraries — tested on real hardware.
What You Will Learn
- Know how OLEDs differ from character LCDs
- Understand display buffers
A 128×64 OLED has individually controlled pixels, so it can draw shapes, graphs and any font. Libraries keep a copy of the screen in RAM (a buffer); you draw into it, then call display() to send it.
Arduino C++
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
void setup() {
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
oled.clearDisplay();
oled.setTextSize(2);
oled.setTextColor(SSD1306_WHITE);
oled.setCursor(0, 0);
oled.println("Robotry");
oled.display();
}
void loop() {}The 128×64 buffer uses 1 KB — half of the Uno's RAM. Large sketches with an OLED can run out of memory on the Uno; the ESP32 has plenty.
OLED graphics aren't simulated in Robotry Labs yet. You can place and wire the OLED in the Circuit Lab, but run this sketch on a real board.
Check Your Understanding
Test what you learned in this lesson