PinoutSearch

OLED Display Hello World (SSD1306 + Arduino)

Show text on a 128×64 I²C OLED display. Learn the I²C bus and the Adafruit graphics libraries.

Beginner20 min

What you need

Wiring

Hover a pin or a wire to trace the connection.

Code

oled_hello.ino
// Print "Hello!" on a 128x64 SSD1306 OLED over I2C.
// Install "Adafruit SSD1306" and "Adafruit GFX" libraries.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 display(128, 64, &Wire, -1);

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // 0x3C is the usual address
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 20);
  display.println("Hello!");
  display.display();
}

void loop() {}

Steps

  1. Install "Adafruit SSD1306" and "Adafruit GFX" via Library Manager.
  2. Wire the OLED: VCC to 5V, GND to GND, SDA to A4, SCL to A5.
  3. Upload — "Hello!" appears. If the screen stays black, try address 0x3D.