How to use a 0.96" OLED with Arduino (SSD1306)
What is the OLED SSD1306?
The 0.96" OLED SSD1306 is a crisp, low-power screen that supports 128x64 pixels in monochrome. Unlike LCDs, OLEDs emit their own light, meaning:
- No need for a backlight
- Better contrast
- Smaller and more energy-efficient
It communicates with the Arduino using I2C, saving pins and simplifying wiring.
Components Used
- Arduino UNO (or compatible board)
- OLED 128x64 I2C display (SSD1306 driver)
- Analog joystick
- Jumper wires + breadboard
Wiring Diagram

OLED Pin | Arduino UNO |
---|---|
GND | GND |
VCC | 5V |
SCL | A5 |
SDA | A4 |
Joystick VRx | A0 |
Required Arduino Libraries
Before uploading the code, install these via the Library Manager:
- Adafruit GFX
- Adafruit SSD1306
Go to: Sketch > Include Library > Manage Libraries
Search for “Adafruit GFX” and “Adafruit SSD1306” → Install both
Arduino Code
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
int lastValue = -1;
void setup() {
pinMode(A0, INPUT);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
while (true); // Freeze if screen fails
}
display.clearDisplay();
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
display.setCursor(0, 0);
display.println("SOSLab.net");
display.display();
delay(1000); // Welcome screen
}
void loop() {
int readJoy = analogRead(A0);
if (abs(readJoy - lastValue) > 2) {
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0, 0);
display.println("Joystick Reading:");
display.setTextSize(2);
display.setCursor(0, 20);
display.print(readJoy);
display.setTextSize(1);
display.setCursor(0, 50);
display.print("soslab.net");
display.display();
lastValue = readJoy;
}
delay(10); // Smooth update
}
Why Use abs(readJoy - lastValue) > 2
?
Analog sensors like joysticks often produce minor noise, even when still.
Using this line reduces unnecessary screen updates, preventing flickering and saving resources.
Project in Action

Summary
- Displayed analog joystick values on a 128x64 OLED
- Used I2C for simple wiring
- Prevented flickering with change detection
- Fully working and scalable for other sensor readings
Check out our previous article using LCD 1602 I2C:
"Displaying Joystick Value on an LCD 1602 with Arduino"
Frequently Asked Questions
How to: How to use a 0.96" OLED with Arduino (SSD1306)
In this tutorial, we’ll learn how to use a 128x64 I2C OLED screen (SSD1306) to display analog joystick values using an Arduino. We’ll also optimize the cod
Required Supplies
- Arduino Board
- Jumper Wires
- Breadboard
- LED
- Resistor
Required Tools
- Arduino IDE
- USB Cable
- Computer
Steps
1Setup Development Environment
2Connect Hardware Components
3Write and Upload Code
4Test and Troubleshoot
Comments (0)
No comments yet. Be the first to comment!
Leave a Comment