Realistic OLED Eyes Animation using Arduino UNO (Wokwi Simulation)

 

Create expressive animated robot eyes using the Arduino Uno and an SSD1306 OLED display in the Wokwi simulator. This beginner-friendly project displays smooth blinking, eye movement, and subtle expression effects on a 128×64 OLED screen — perfect for robotics and humanoid bot faces.


 Components Required (Wokwi)

  • Arduino Uno

  • SSD1306 128×64 OLED Display (I2C)

  • Jumper wires (virtual in Wokwi)


Circuit Connections (I2C)

OLED PinArduino Uno
VCC5V
GNDGND
SDAA4
SCLA5



 Working Principle

  • The SSD1306 OLED communicates with Arduino using I2C protocol (SDA & SCL).

  • Using Adafruit GFX and Adafruit SSD1306 libraries:

    • Two large eye shapes are drawn using circles.

    • Pupils shift left and right to simulate eye movement.

    • Lines simulate blinking.

    • Slight radius changes create expression effects.

  • Animation is achieved using display.clearDisplay(), redraw logic, and timed delay().


 Features of This Project

  • Smooth OLED eye animation

  • Natural blinking at random intervals

  • Realistic left-right pupil tracking

  • I2C communication with SSD1306

  • Fully testable in Wokwi simulator

  • Perfect robot face UI project


 Applications

This animated OLED eye system is widely used in:

  • Robot face displays

  • DIY AI assistants

  • Humanoid robots

  • Interactive art projects

  • STEM robotics workshops

Since you're actively building robotics and Arduino projects, this can be a great face module for your robot car or IoT robot builds — especially for school demonstrations or robotics competitions.


 Learning Outcomes

  • Using SSD1306 OLED with Arduino

  • Understanding I2C communication

  • Creating frame-based animations

  • Managing timing with millis()

  • Designing expressive robot interfaces


 Circuit Connections (I2C)

Diagram.json:
{
  "version": 1,
  "author": "Wokwi",
  "editor": "wokwi",
  "parts": [
    { "type": "wokwi-arduino-uno", "id": "uno", "top": 0, "left": 0, "attrs": {} },
    { "type": "wokwi-ssd1306", "id": "oled", "top": -100, "left": 100, "attrs": {} }
  ],
  "connections": [
    [ "oled:GND", "uno:GND.1", "black", [ "v0" ] ],
    [ "oled:VCC", "uno:5V", "red", [ "v0" ] ],
    [ "oled:SDA", "uno:A4", "blue", [ "v0" ] ],
    [ "oled:SCL", "uno:A5", "green", [ "v0" ] ]
  ]
}


OLED PinArduino Uno
VCC5V
GNDGND
SDAA4
SCLA5

 Features of This Project

  • Smooth OLED eye animation

  • I2C communication with SSD1306

  • Beginner-friendly Arduino project

  • Fully testable in Wokwi simulator

  • Perfect for robotics face display

Code:
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1

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

void setup() {
  Serial.begin(9600);
  Serial.println("Starting OLED Eyes...");
 
  // Try to initialize display at address 0x3C
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println("SSD1306 allocation failed");
    // Try alternate address
    if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3D)) {
      Serial.println("Failed at 0x3D too");
      for(;;); // Don't proceed, loop forever
    }
  }
 
  Serial.println("Display initialized!");
  display.clearDisplay();
  display.display();
}

void loop() {
  // Clear display
  display.clearDisplay();
 
  // Draw left eye
  display.fillCircle(40, 32, 18, SSD1306_WHITE);  // White circle
  display.fillCircle(40, 32, 16, SSD1306_BLACK);  // Black inner
  display.fillCircle(45, 32, 8, SSD1306_WHITE);   // White pupil
 
  // Draw right eye
  display.fillCircle(88, 32, 18, SSD1306_WHITE);  // White circle
  display.fillCircle(88, 32, 16, SSD1306_BLACK);  // Black inner
  display.fillCircle(93, 32, 8, SSD1306_WHITE);   // White pupil
 
  display.display();
  delay(1000);
 
  // Blink
  display.clearDisplay();
  // Draw closed eyes
  display.drawLine(25, 32, 55, 32, SSD1306_WHITE);
  display.drawLine(73, 32, 103, 32, SSD1306_WHITE);
  display.display();
  delay(150);
 
  // Look left
  display.clearDisplay();
  display.fillCircle(40, 32, 18, SSD1306_WHITE);
  display.fillCircle(40, 32, 16, SSD1306_BLACK);
  display.fillCircle(35, 32, 8, SSD1306_WHITE);
 
  display.fillCircle(88, 32, 18, SSD1306_WHITE);
  display.fillCircle(88, 32, 16, SSD1306_BLACK);
  display.fillCircle(83, 32, 8, SSD1306_WHITE);
  display.display();
  delay(1000);
 
  // Look right
  display.clearDisplay();
  display.fillCircle(40, 32, 18, SSD1306_WHITE);
  display.fillCircle(40, 32, 16, SSD1306_BLACK);
  display.fillCircle(45, 32, 8, SSD1306_WHITE);
 
  display.fillCircle(88, 32, 18, SSD1306_WHITE);
  display.fillCircle(88, 32, 16, SSD1306_BLACK);
  display.fillCircle(93, 32, 8, SSD1306_WHITE);
  display.display();
  delay(1000);
}



 

Comments