How to make a Robot Eye Animation project using OLED display with Arduino

Hello and welcome back! In this project, we’ll learn how to make a robot eye animation project using an Arduino. For this project, I used a 128×64 OLED display and a sound sensor module. You can use this setup to make cute robots, similar to Vector. Also, I used three different eye animations, and we can switch between them by detecting sounds. For example, when you clap or make a noise, the robot changes its eye expression automatically. You can also add more animations if you want, such as angry, happy, smile, sleepy, or even tired eyes. If you want to know more info about the OLED display, please use this link.
Ok, let’s do this project step by step. The required components are given below.
- Arduino UNO R4 MINIMA — Our Store / Amazon
- Sound-sensitive sensor — Our Store / Amazon
- OLED display x 1 — Our Store / Amazon
- 5V Active buzzer x 1 — Our store / Amazon
- Breadboard x 1 — Our Store / Amazon
- Jumper wires — Our Store / Amazon
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Step 1
Firstly, identify these components.






Step 2
Secondly, place the OLED display on the breadboard and connect it to the Arduino board. Use the circuit diagram below as a reference to make the correct connections.






Step 3
Thirdly, place the sound sensor module on the breadboard and connect it to the Arduino board.



Step 4
Next, connect the buzzer to the Arduino board, and then plug the Arduino board into your computer using a USB cable. After that, copy and paste the following program into the Arduino IDE. You also need to install the following library files in the Arduino IDE before uploading the code.


#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <FluxGarage_RoboEyes.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// create RoboEyes instance
RoboEyes<Adafruit_SSD1306> roboEyes(display);
#define Ssensor 2
#define buzzer 3
unsigned long lastSound = 0;
int debounceTime = 800; // 0.8s debounce
// Multi-sound detection
unsigned long firstSoundTime = 0;
int soundCount = 0;
const unsigned long multiSoundWindow = 2000; // 2 seconds window
// Mood reset
unsigned long moodChangedTime = 0;
bool moodChanged = false;
// Idle cute sound
unsigned long lastIdleSound = 0;
const unsigned long idleSoundInterval = 5000; // play every 5 seconds
// Function to play buzzer patterns per mood
void playBuzzerForMood(String mood) {
if (mood == "ANGRY") {
for (int i = 0; i < 2; i++) {
tone(buzzer, 1000);
delay(80);
noTone(buzzer);
delay(80);
}
} else if (mood == "HAPPY") {
for (int i = 0; i < 3; i++) {
tone(buzzer, 1500);
delay(50);
noTone(buzzer);
delay(50);
}
} else if (mood == "TIRED") {
tone(buzzer, 600);
delay(300);
noTone(buzzer);
} else if (mood == "DEFAULT") {
// cute idle chirp
tone(buzzer, random(1800, 2200)); // random high pitch
delay(40);
noTone(buzzer);
}
}
void setup() {
pinMode(Ssensor, INPUT);
pinMode(buzzer, OUTPUT);
digitalWrite(buzzer, LOW);
Serial.begin(9600);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.clearDisplay();
display.display();
roboEyes.begin(SCREEN_WIDTH, SCREEN_HEIGHT, 100);
roboEyes.setAutoblinker(ON, 8, 2);
roboEyes.setIdleMode(ON, 2, 1);
roboEyes.setMood(DEFAULT);
roboEyes.open();
}
void loop() {
unsigned long currentMillis = millis();
// --- Sound detection ---
if (digitalRead(Ssensor) == HIGH && (currentMillis - lastSound > debounceTime)) {
lastSound = currentMillis;
if (firstSoundTime == 0 || (currentMillis - firstSoundTime > multiSoundWindow)) {
firstSoundTime = currentMillis;
soundCount = 1;
} else {
soundCount++;
}
// --- Choose action based on number of sounds ---
if (soundCount == 1) {
roboEyes.setMood(ANGRY);
roboEyes.blink();
roboEyes.open();
playBuzzerForMood("ANGRY");
moodChangedTime = currentMillis;
moodChanged = true;
}
else if (soundCount == 2) {
roboEyes.setMood(HAPPY);
roboEyes.anim_laugh();
playBuzzerForMood("HAPPY");
moodChangedTime = currentMillis;
moodChanged = true;
}
else if (soundCount >= 3) {
roboEyes.setMood(TIRED);
roboEyes.anim_confused();
playBuzzerForMood("TIRED");
soundCount = 0;
firstSoundTime = 0;
moodChangedTime = currentMillis;
moodChanged = true;
}
}
// --- Reset mood after 3 seconds ---
if (moodChanged && currentMillis - moodChangedTime > 3000) {
roboEyes.setMood(DEFAULT);
moodChanged = false;
}
// --- Idle cute sound ---
if (!moodChanged && currentMillis - lastIdleSound > idleSoundInterval) {
lastIdleSound = currentMillis;
playBuzzerForMood("DEFAULT");
}
// --- Update RoboEyes animations ---
roboEyes.update();
// Reset counter if too much time passed
if (firstSoundTime > 0 && currentMillis - firstSoundTime > multiSoundWindow) {
soundCount = 0;
firstSoundTime = 0;
}
}
- Now, select the board and port. After, click the upload button.



Step 5
Finally, you can test your project using sounds and see how the eye animations react. The full project guide is given below for more details. We hope to see you again in the next project. Have a great day and happy making!

How to make a Robot Eyes Animation project using OLED display with Arduino