Introduction
The ESP32 OLED Eye Blink Project is a fun and creative embedded systems project that uses an ESP32 microcontroller and an OLED display to simulate realistic eye movements and blinking effects. This project is widely used in robotics, smart toys, humanoid robots, educational demonstrations, and interactive IoT applications.
The OLED screen displays animated eyes that can move, blink, wink, and express emotions, making it an excellent project for learning graphics programming, display interfacing, and ESP32 development.
Project Objectives
- Interface an OLED display with ESP32.
- Create eye animation graphics.
- Implement automatic blinking effects.
- Learn I2C communication protocol.
- Develop interactive robotic face displays.
Buy From Amazon
ESP32 https://amzn.to/4fx4wDA
OLED https://amzn.to/4vDH6Bq
Circuit Diagram
OLED to ESP32 Connections
| OLED Pin | ESP32 Pin |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SDA | GPIO 21 |
| SCL | GPIO 22 |
Software Requirements
- Arduino IDE
- ESP32 Board Package
- Adafruit SSD1306 Library
- Adafruit GFX Library
Install the libraries from:
Arduino IDE → Library Manager
- Adafruit SSD1306
- Adafruit GFX
#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);
void drawEyes(int height)
{
display.clearDisplay();
// Left Eye
display.fillRoundRect(20, 20, 30, height, 8, WHITE);
// Right Eye
display.fillRoundRect(78, 20, 30, height, 8, WHITE);
display.display();
}
void setup()
{
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C))
{
while(true);
}
display.clearDisplay();
}
void loop()
{
// Open eyes
drawEyes(20);
delay(3000);
// Blink animation
for(int h=20; h>2; h--)
{
drawEyes(h);
delay(20);
}
delay(100);
// Open eyes again
for(int h=2; h<20; h++)
{
drawEyes(h);
delay(20);
}
}
Working Principle
- ESP32 initializes the SSD1306 OLED display through the I2C interface.
- Two rounded rectangles are drawn to represent eyes.
- The eye height is gradually reduced to simulate closing.
- The eye height is gradually increased to simulate opening.
- The process repeats continuously, creating a realistic blinking effect.
Applications
- Humanoid Robots
- Smart Toys
- Educational Robotics
- AI Companion Devices
- Interactive Displays
- IoT Demonstration Projects
- Robot Face Animation Systems
Project Enhancements
You can further improve the project by adding:
- Servo-controlled eye movement
- Face tracking camera
- Voice interaction
- Different emotions (happy, sad, angry)
- Bluetooth control using ESP32
- Gesture recognition
- AI chatbot integration
Expected Output
The OLED display shows two animated eyes that:
- Stay open for a few seconds.
- Close smoothly during blinking.
- Open again automatically.
- Repeat the animation continuously.
Conclusion
The ESP32 OLED Eye Blink Project is an excellent beginner-to-intermediate embedded systems project that combines graphics programming with hardware interfacing. It provides practical experience in OLED display control, animation techniques, and ESP32 programming while creating an engaging visual effect suitable for robotics and IoT applications
