Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO with I2C OLED Display Interface

View and Edit Project In Cirkit DesignerImage of Arduino UNO with I2C OLED Display Interface

Circuit Documentation

Summary of the Circuit

This circuit consists of an Arduino UNO microcontroller board interfaced with a 128x64 OLED display using I2C communication protocol. The OLED display is powered by the 5V supply from the Arduino and communicates over the SDA and SCL lines. The ground of both the Arduino and the OLED display is connected to establish a common reference point for the voltages. The purpose of this circuit is to display the message "Hello, World!" on the OLED screen.

Component List

128x64 OLED Display (I2C IIC SPI Serial)

Arduino UNO

Wiring Details

128x64 OLED Display (I2C IIC SPI Serial)

Arduino UNO

Documented Code

Arduino UNO Code

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

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1  // Reset pin is not used with some OLED displays

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {
  if(!display.begin(SSD1306_I2C_ADDRESS, OLED_RESET)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Halt if display initialization fails
  }
  display.display();
  delay(2000);  // Pause for 2 seconds

  display.clearDisplay();
  
  display.setTextSize(1);       // Normal 1:1 pixel scale
  display.setTextColor(SSD1306_WHITE); // White text
  display.setCursor(0,0);       // Start at top-left corner
  display.print(F("Hello, World!"));
  display.display();
}

void loop() {
  // Nothing needed in loop for static display
}

File Name: sketch.ino

This code initializes the OLED display and prints "Hello, World!" on the screen. The setup() function begins by initializing the display with the display.begin() function. If the initialization fails, the program enters an infinite loop, effectively halting the system. If successful, it clears the display and sets the text size and color before setting the cursor position and printing the message. The loop() function is left empty as the display content is static.