Arduino UNO R4 - SSD1309 OLED Display
Organic Light-Emitting Diode (OLED) displays feature self-illuminating pixels that produce true blacks, superior contrast ratios, and excellent viewing angles from all directions — providing significant advantages over conventional LCD technology. The SSD1309 driver chip powers the 2.42-inch (also marketed as 2.4-inch) 128×64 monochrome OLED modules using I2C communication.

This hands-on guide walks you through interfacing the SSD1309 OLED 128×64 with your Arduino Uno R4 board via the DIYables_OLED_SSD1309 library. You will discover how to:
- Wire the 2.42-inch SSD1309 OLED to Arduino Uno R4 using the I2C bus
- Display text strings and numerical values on the screen
- Position text at the center horizontally and vertically
- Render geometric primitives (lines, rectangles, circles, triangles, rounded shapes)
- Show monochrome bitmap graphics
- Activate hardware scrolling in multiple directions
- Control display brightness and contrast levels
- Integrate custom typefaces from the Adafruit GFX font library
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (30 sensors/displays) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of the SSD1309 2.42-Inch OLED Display
The SSD1309 serves as a dedicated CMOS driver IC engineered for 128×64 pixel OLED matrices. Its register set maintains compatibility with the popular SSD1306, enabling code reuse with minor adjustments. Notable hardware distinctions include:
- External power requirement — unlike the SSD1306's integrated charge pump, the SSD1309 relies on an external VCC supply. However, commercially available breakout boards (including 2.42-inch and 2.4-inch variants) incorporate onboard boost converters, making this difference transparent during use.
- Extended voltage range — the SSD1309 handles up to 16 V VCC input, whereas the SSD1306 caps at approximately 4.2 V.
The 2.42 inch (2.4 inch) OLED module typically employs the SSD1309 controller and provides a 128×64 resolution display communicating via I2C protocol. Display color (white, blue, yellow, green, or dual-color zones) depends on the physical OLED substrate and cannot be modified through software commands.
This tutorial interfaces with the display through the I2C bus, requiring only two signal lines (SDA and SCL) and allowing bus sharing with additional I2C peripherals.
SSD1309 OLED Pinout (I2C Module)
Standard 2.42-inch SSD1309 I2C OLED modules feature four connection pins:
- GND — Connect to Arduino Uno R4 ground reference.
- VCC — Power supply input. Wire to Arduino Uno R4 5 V output (or 3.3 V if module supports it).
- SCL — I2C clock signal line.
- SDA — I2C data signal line.

※ NOTE THAT:
- Pin arrangement differs between manufacturers. Always verify the silkscreen labels on your specific module before making connections.
- This guide has been validated with the 2.42 inch SSD1309 OLED display from DIYables. Other SSD1309-based 2.4/2.42-inch modules should function identically.
Wiring Diagram — Arduino Uno R4 & SSD1309 OLED 128×64
- Schematic connections between Arduino Uno R4 and the 2.42 inch SSD1309 OLED 128×64

This image is created using Fritzing. Click to enlarge image
- Physical wiring photograph between Arduino Uno R4 and SSD1309 OLED 128×64

This image is created using Fritzing. Click to enlarge image
See The best way to supply power to the Arduino Uno R4 and other components.
The Arduino Uno R4 uses the same I2C pin locations as the classic Uno. Connection details:
| OLED Module | Arduino Uno R4 |
|---|---|
| Vin | 5V |
| GND | GND |
| SDA | A4 (or SDA pin) |
| SCL | A5 (or SCL pin) |
Getting Started — SSD1309 OLED with Arduino Uno R4
Step 1: Install the DIYables_OLED_SSD1309 Library
- Launch the Arduino IDE and click the Libraries icon on the left sidebar.
- Enter "DIYables_OLED_SSD1309" in the search field and find the library by DIYables.
- Click the Install button.

- The IDE will prompt you to install the required dependency (Adafruit GFX Library). Click Install All.

Step 2: Basic Programming Structure
All SSD1309 sketches follow this consistent structure: include headers, instantiate a display object, initialize it in setup(), draw content into the frame buffer, then transfer the buffer to the screen using display().
- Include necessary headers:
- Define the screen dimensions (128×64 for the 2.42-inch module):
- Instantiate the display object (use -1 when no reset pin is connected):
- Initialize the display inside setup():
- After initialization, call drawing functions (clearDisplay(), drawPixel(), print(), etc.) followed by oled.display() to refresh the screen.
※ NOTE THAT:
All code examples in this guide target the SSD1309 OLED 128×64 (2.42 inch) and use the DIYables_OLED_SSD1309 library with Arduino Uno R4.
Arduino Uno R4 Code — Hello World on SSD1309 OLED
The simplest demonstration: display text at multiple sizes.
Arduino Uno R4 Code — Display Text on SSD1309 OLED
This example showcases advanced text features — variable sizes, numeric formatting, and the F() macro for RAM conservation.
Useful Display Functions Reference
Quick reference for commonly-used SSD1309 OLED functions via the DIYables library:
- oled.clearDisplay() — erase the frame buffer (all pixels off).
- oled.display() — transfer the buffer to the OLED to make changes visible.
- oled.drawPixel(x, y, color) — set or clear a single pixel.
- oled.setTextSize(n) — scale the font by factor *n* (1 = 6×8, 2 = 12×16, …, up to 8).
- oled.setCursor(x, y) — position the text cursor at pixel coordinates *(x, y)*.
- oled.setTextColor(SSD1309_PIXEL_ON) — text foreground only (transparent background).
- oled.setTextColor(SSD1309_PIXEL_OFF, SSD1309_PIXEL_ON) — text with explicit background color.
- oled.println("message") — print a string and move to the next line.
- oled.println(number) — print an integer in decimal format.
- oled.println(number, HEX) — print an integer in hexadecimal format.
- oled.startscrollright(start, stop) — hardware-scroll right between page *start* and page *stop*.
- oled.startscrollleft(start, stop) — hardware-scroll left.
- oled.startscrolldiagright(start, stop) — hardware-scroll diagonally right.
- oled.startscrolldiagleft(start, stop) — hardware-scroll diagonally left.
- oled.stopscroll() — halt any active hardware scroll.
- oled.setContrast(value) — adjust display brightness (0–255).
- oled.dim(true/false) — quickly dim the display to minimum or restore previous contrast.
- oled.invertDisplay(true/false) — hardware-level color inversion (on pixels ↔ off pixels).
How to Vertically and Horizontally Center Text on the SSD1309 OLED
Arduino Uno R4 Code — Draw Shapes on SSD1309 OLED
The DIYables_OLED_SSD1309 library inherits from Adafruit_GFX, providing complete shape-drawing capabilities: pixels, lines, rectangles, filled rectangles, circles, filled circles, triangles, filled triangles, and rounded rectangles. The following sketch demonstrates all of them with animated sequences.
Arduino Uno R4 Code — Hardware Scrolling on SSD1309 OLED
The SSD1309 includes a hardware scrolling engine that moves display content without CPU intervention. The DIYables library exposes four scroll modes: right, left, diagonal-right, and diagonal-left. Each accepts a start page and stop page parameter (pages are 8-pixel-tall horizontal bands numbered 0–7 on a 64-pixel-tall display).
※ NOTE THAT:
Always call display() to transfer your content to the OLED before initiating a scroll. Avoid rendering new content while scrolling is active — call stopscroll() first.
Arduino Uno R4 Code — Display Bitmap Image on SSD1309 OLED
To display a bitmap on the SSD1309 OLED you must first convert your image into a C byte array. Use the free image2cpp online tool for this conversion:
- Upload your image file (PNG, JPG, BMP, etc.).
- Configure the canvas size to 128×64 (or smaller).
- Select Arduino code as the output format.
- Copy the generated array into your sketch.

The example below alternates between a 16×16 heart icon and a full-width DIYables logo:
※ NOTE THAT:
- Bitmap dimensions must not exceed the screen resolution (128×64 for the 2.42 inch module).
Arduino Uno R4 Code — Contrast and Dim on SSD1309 OLED
The SSD1309 offers 256 contrast levels (0–255). The DIYables library provides setContrast() for precise control and dim() for quick toggling between minimum brightness and the previously-set level.
Arduino Uno R4 Code — Custom External Fonts on SSD1309 OLED
The Adafruit GFX library includes dozens of scalable FreeFont typefaces (Serif, Sans, Mono — each in Regular, Bold, Italic, and multiple sizes). You can use any of them on the SSD1309 display by including the relevant header and calling setFont().
※ NOTE THAT:
- When an external font is active, the cursor Y coordinate refers to the text baseline, not the top-left corner. This differs from the built-in 5×7 font behavior.
- External fonts are stored in flash (PROGMEM). On memory-constrained boards like the classic Uno (32 KB flash), use them judiciously. The Arduino Uno R4 has more memory, allowing more flexibility.
SSD1309 OLED Troubleshooting with Arduino Uno R4
If the 2.42 inch SSD1309 OLED remains blank after uploading your sketch, work through these diagnostic steps:
- Verify connections — confirm SDA, SCL, VCC and GND are wired to the correct Arduino Uno R4 pins.
- Confirm the driver chip — this library is designed for the SSD1309. If your module uses a different controller (e.g. SH1106), it won't respond correctly.
- Check the I2C address — most SSD1309 modules default to 0x3C, but some use 0x3D. Run the I2C scanner sketch below to detect the actual address:
Expected Serial Monitor output when the SSD1309 is detected:
- Ensure display() is called — the SSD1309 uses a frame buffer. Drawing functions only modify the buffer in RAM; nothing appears on screen until you call oled.display().
- Check power supply — the 2.42 inch module draws more current than smaller OLEDs. Ensure your power source can deliver sufficient current (typically 20–40 mA at full brightness).