Robotic Eyes Using Arduino and OLED Display

Creating robotic eyes using an OLED display is a popular and visually impressive project in robotics. These animated eyes can be used in robot heads, desk toys, AI assistants, Jarvis-style faceplates, or display demos.

In this project, we will use Arduino and a 0.96-inch OLED display to create realistic robotic eyes with pupil movement and blinking animation.


Project Overview

Features of this project:

  • Two human-like eyes
  • Smooth random pupil movement
  • Natural blinking animation
  • Lightweight and beginner-friendly code
  • Uses I2C OLED (minimum wiring)

Components Required

ComponentQuantity
Arduino UNO / Nano1
0.96″ OLED Display (SSD1306, I2C)1
Jumper WiresAs required
Breadboard (optional)1

OLED Display Specifications

  • Resolution: 128 × 64 pixels
  • Driver IC: SSD1306
  • Interface: I2C
  • Operating Voltage: 3.3V / 5V

Circuit Connections (Wiring)

The OLED uses the I2C protocol, so only four connections are required.

OLED to Arduino UNO / Nano

OLED PinArduino Pin
VCC5V
GNDGND
SDAA4
SCLA5

If your OLED supports only 3.3V, connect VCC to 3.3V instead of 5V.


Required Arduino Libraries

Install the following libraries from Arduino Library Manager:

  1. Adafruit SSD1306
  2. Adafruit GFX

Steps:

  1. Open Arduino IDE
  2. Go to Sketch → Include Library → Manage Libraries
  3. Search and install both libraries

How the Eye Animation Works

Eye Design Logic

  • White circle → eye sclera
  • Black small circle → pupil
  • Random pupil offsets simulate eye movement
  • Rectangles simulate eyelids for blinking

OLED Coordinate System

  • Origin (0,0) is at the top-left
  • X increases → right
  • Y increases → downward

Arduino Code (Robotic Eyes)

This is exactly the code you requested
Copy and upload it directly to your Arduino.

#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);

// Eye positions
int eyeY = 32;
int leftEyeX = 42;
int rightEyeX = 86;

// Sizes
int eyeRadius = 16;
int pupilRadius = 5;

// Pupil movement
int pupilX = 0;
int pupilY = 0;

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  randomSeed(analogRead(0));
}

void loop() {
  moveEyes();
  blink();
}

// -------- FUNCTIONS --------

void drawEye(int eyeX, int pupilOffsetX, int pupilOffsetY) {
  // Eye white
  display.fillCircle(eyeX, eyeY, eyeRadius, SSD1306_WHITE);

  // Pupil (black)
  display.fillCircle(
    eyeX + pupilOffsetX,
    eyeY + pupilOffsetY,
    pupilRadius,
    SSD1306_BLACK
  );
}

void drawEyes() {
  display.clearDisplay();
  drawEye(leftEyeX, pupilX, pupilY);
  drawEye(rightEyeX, pupilX, pupilY);
  display.display();
}

void moveEyes() {
  for (int i = 0; i < 15; i++) {
    pupilX = random(-6, 6);
    pupilY = random(-4, 4);
    drawEyes();
    delay(random(200, 500));
  }
}

void blink() {
  for (int h = 0; h < eyeRadius * 2; h += 4) {
    display.clearDisplay();
    display.fillRect(leftEyeX - eyeRadius, eyeY - eyeRadius, eyeRadius * 2, h, SSD1306_BLACK);
    display.fillRect(rightEyeX - eyeRadius, eyeY - eyeRadius, eyeRadius * 2, h, SSD1306_BLACK);
    display.display();
    delay(20);
  }
  delay(80);
}

Output Behavior

✔ Eyes randomly look around
✔ Pupils stay inside eye boundary
✔ Natural blinking effect
✔ Smooth animation on OLED


Common Issues & Fixes

ProblemSolution
Blank OLEDCheck I2C address (0x3C / 0x3D)
OLED not detectedCheck SDA/SCL wiring
FlickerReduce refresh rate
No blinkEnsure loop() runs continuously

Applications

  • Robot head / humanoid robot
  • AI assistant face
  • Desk toy / showpiece
  • YouTube electronics demo
  • Exhibition robotics project

Conclusion

This project demonstrates how a simple Arduino + OLED can create lifelike robotic eyes using basic graphics and logic. With small enhancements, it can be expanded into a full robotic face or AI assistant display.