Arduino SSD1306 OLED Display: Wiring, Code and Simulator
To build this Arduino SSD1306 OLED Display project you need an Arduino Uno and an SSD1306 OLED display. A 128×64 SSD1306 OLED over I²C, drawn with Adafruit GFX: text, a frame and a moving ball. Make the 4 connections in the wiring table, upload the Arduino C++ code, and watch the ball roll. Each frame, display() sends all 1024 bytes of pixels over two wires.
Open this circuit in the free Arduino Uno simulator
Parts list
| Qty | Part | What it does |
|---|---|---|
| 1 | Arduino Uno | the microcontroller board |
| 1 | SSD1306 OLED display | SSD1306 over I²C: DATA (SDA) to A4, CLK (SCL) to A5, VIN to 5V, GND to GND. Address 0x3C. |
Wiring
| # | From | To |
|---|---|---|
| 1 | Arduino Uno A4 | SSD1306 OLED display DATA |
| 2 | Arduino Uno A5 | SSD1306 OLED display CLK |
| 3 | Arduino Uno 5V | SSD1306 OLED display VIN |
| 4 | Arduino Uno GND | SSD1306 OLED display GND |
Step by step
- Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
- Add the parts. Add an SSD1306 OLED display from the parts palette.
- Wire 1. Connect Arduino Uno A4 to SSD1306 OLED display DATA.
- Wire 2. Connect Arduino Uno A5 to SSD1306 OLED display CLK.
- Wire 3. Connect Arduino Uno 5V to SSD1306 OLED display VIN.
- Wire 4. Connect Arduino Uno GND to SSD1306 OLED display GND.
- Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
- Run it. Press Run. Watch the ball roll. Each frame, display() sends all 1024 bytes of pixels over two wires.
Arduino C++ code
// OLED: draw text and shapes on a 128x64 SSD1306 over I2C (address 0x3C).
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display(128, 64, &Wire, -1);
void setup() {
Serial.begin(9600);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println("SSD1306 not found. Check SDA (A4) and SCL (A5).");
for (;;) {}
}
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(4, 4);
display.println("Hello!");
display.drawRect(0, 0, 128, 64, SSD1306_WHITE);
display.display();
Serial.println("Drawn.");
}
void loop() {
static int x = 8;
display.fillRect(1, 40, 126, 20, SSD1306_BLACK);
display.fillCircle(x, 50, 6, SSD1306_WHITE);
display.display();
x = x >= 120 ? 8 : x + 4;
}
What to try
Watch the ball roll. Each frame, display() sends all 1024 bytes of pixels over two wires.
Frequently asked questions
How do I wire the SSD1306 OLED Display project on an Arduino Uno?
Make 4 connections: Arduino Uno A4 to SSD1306 OLED display DATA; Arduino Uno A5 to SSD1306 OLED display CLK; Arduino Uno 5V to SSD1306 OLED display VIN; Arduino Uno GND to SSD1306 OLED display GND.
What parts do I need for this Arduino project?
An Arduino Uno and an SSD1306 OLED display.
Can I simulate this Arduino project online for free?
Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.
What does the code do?
A 128×64 SSD1306 OLED over I²C, drawn with Adafruit GFX: text, a frame and a moving ball.
More Arduino Uno projects
- Arduino LED Blink: Wiring, Code and Simulator
- Arduino LDR Light Sensor: Wiring, Code and Simulator
- Arduino NTC Thermistor Thermometer: Wiring, Code and Simulator
- Arduino PWM to Analog RC Filter: Wiring, Code and Simulator
- Arduino Capacitance Meter: Wiring, Code and Simulator
- Arduino DC Motor PWM Speed Control with MOSFET: Wiring, Code and Simulator