Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino Nano Controlled OLED Display Interface

Image of Arduino Nano Controlled OLED Display Interface

Circuit Documentation

Summary of the Circuit

This circuit consists of an Arduino Nano microcontroller connected to an OLED 128x64 I2C Monochrome Display. The Arduino Nano serves as the central processing unit, controlling the display output on the OLED screen. The OLED display is interfaced with the Arduino Nano via the I2C communication protocol, using two data lines: SCK (Serial Clock) and SDA (Serial Data). The display is powered by the 5V output from the Arduino Nano, and both devices share a common ground.

Component List

Arduino Nano

  • Description: A compact microcontroller board based on the ATmega328P.
  • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK.

OLED 128x64 I2C Monochrome Display

  • Description: A small graphical display with 128x64 pixel resolution, using I2C for communication.
  • Pins: GND, VDD, SCK, SDA.

Wiring Details

Arduino Nano

  • GND connected to OLED Display GND.
  • 5V connected to OLED Display VDD.
  • A5 connected to OLED Display SCK.
  • A4 connected to OLED Display SDA.

OLED 128x64 I2C Monochrome Display

  • GND connected to Arduino Nano GND.
  • VDD connected to Arduino Nano 5V.
  • SCK connected to Arduino Nano A5.
  • SDA connected to Arduino Nano A4.

Documented Code

The following code is written for the Arduino Nano to control the OLED display using the Adafruit libraries for the SSD1306 OLED driver and GFX graphics library.

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);

void setup() {
  // Initialize with the I2C addr 0x3C (for the 128x64)
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }

  // Clear the buffer
  display.clearDisplay();

  // Draw a single pixel in white
  display.drawPixel(10, 10, WHITE);

  // Display the drawing
  display.display();
}

void loop() {
  // put your main code here, to run repeatedly:
}

This code initializes the display and checks for successful communication with the OLED module. If the initialization fails, it enters an infinite loop, effectively halting the program. If successful, it clears the display buffer, draws a single pixel at position (10, 10), and then updates the display to show the pixel. The loop() function is left empty as the example code does not include any repeated actions.