OLED Animation Maker OLED Maker
👀 Robot Eyes · GFX

Arduino Robot Eyes OLED Animation, Blink, Look, Emotion Frames

Every classroom robot looks "alive" the moment it has eyes. Not a photo of eyes pasted as a full-screen bitmap, just two white outlines, pupils that glance sideways, and a blink that collapses the lids. That alone ma...

By Ashish Aug 8, 2026 ~24 min Robot UI, SSD1306, GFX
👀

Expressive eyes

You get blink, look left/right, and happy & sleepy states.

🧮

Vector not bitmaps

You draw circles & lids, so you pay a tiny flash cost on Uno.

⏱️

millis() timing

It's non-blocking, so your sensors still work in loop().

✨

Classroom ready

It's great for your robot heads and demos.

Pixel art of a cute robot face with two big shiny eyes, for the post Arduino Robot Eyes OLED Animation, Blink, Look, Emotion Frames

Every classroom robot looks "alive" the moment it has eyes. You don't need a photo of eyes pasted as a full-screen bitmap. Two white outlines, pupils that glance sideways, and a blink that collapses the lids will do. That alone makes kids lean in, and you'll catch adults smiling at a plastic box. It's a cheap trick, and it works.

OLED Animation Maker editing a robot-eyes template on a 128x64 grid with a live SSD1306 preview

On a 128×64 SSD1306 you have more room than you think. I've shipped this same pattern on scrap Nano boards and on ESP32 heads with dual panels. The trick is geometry plus a tiny state machine. You don't need dozens of full-frame PNGs eating flash. This tutorial walks you through how I draw the eyes with Adafruit GFX, animate look and blink with millis(), add two emotion modes (happy and sleepy), and optionally mirror the look to a second OLED. You'll get a complete sketch at the end.

What you'll build

  • Your left and right eye outlines, plus white "sclera" ellipses (or circles), on your one 128×64 panel
  • Pupils that look center, left or right on a schedule you set
  • A multi-step blink that squashes the open eye into a thin line, then opens it again for you
  • Emotion states you can switch: normal, happy (curved lower lid), sleepy (half lids + slow blink)
  • Non-blocking timing, so you can still read your buttons or sensors in loop()
  • Notes for your dual-OLED robot head (one eye per display)

Want the finished sketch first? You'll find the blink-and-look version in the oled-animation-examples repo on GitHub, along with a two-screen version for a pair of eyes, if you want that.

Parts and wiring

  • An Arduino Uno or Nano (ESP32 works the same for you with different I2C pins)
  • One I2C SSD1306 128×64 (or two if you want your own separate eye panels)
  • Optional: one free digital pin for a demo button that forces a blink when you press it
PartArduino Uno / NanoESP32 (common)
OLED VCC / GND5V / GND3.3V / GND
OLED SDA / SCLA4 / A5GPIO21 / GPIO22
BTN_BLINK (optional)D2 → GND when pressedGPIO0 or any free GPIO
Second OLED (optional)Same bus, and you set address 0x3DSame idea

Confirm your panel answers on 0x3C (or 0x3D) before you argue with eye math. If your screen stays black, use the blank-screen checklist first. Eyes won't fix a dead bus, so don't skip that step.

Why vector eyes beat giant bitmaps (on Uno)

A full 128×64 frame's 1024 bytes in flash when you store it as a PROGMEM bitmap. Eight carefully drawn "emotion frames" as images eat 8 KB before you write a line of behavior. Circles and filled boxes, meanwhile, cost almost no flash. You only pay for the few constants that describe width, height, and pupil offset. On a Uno, that budget difference is your project, and it's the whole reason I draw vectors.

Bitmaps are still the right tool when you want lashes, comic pupils, or brand-specific shapes. I'm not against them. I often start with vectors for the workshop, then I refine one or two hero expressions as bitmaps in the maker tool once the timing feels good to me. You can mix both: vectors for idle life, bitmaps for a special "wake up" animation.

Eye geometry on a 128×64 canvas

Mentally split the screen into two halves. Each eye sits on a center point, and you'll want to pick yours early. Here's roughly what I use:

// screen 128x64 — centers for left and right eyes
const int LEFT_CX  = 40;
const int RIGHT_CX = 88;
const int EYE_CY   = 32;

const int EYE_RX   = 22;   // horizontal radius of sclera
const int EYE_RY   = 18;   // vertical radius (slightly flatter)
const int PUPIL_R  = 6;

Adafruit GFX draws circles with equal radius, so you'll need either a helper that plots the outline or a filled circle plus clipping for a true ellipse. For classroom clarity I often draw a rounded rectangle (or circle) and accept slightly cartoon proportions. You can too. For prettier ovals, mask with upper/lower lids, which you'll need for blink anyway.

Here's a drawing order that stays readable:

  1. Clear the buffer first
  2. Draw each eye outline / filled sclera white, as you'd expect
  3. Punch blacks for the lids if they're partially closed
  4. Draw pupils at (cx + lookX, cy + lookY)
  5. Optional: a tiny highlight pixel offset from the pupil, if you like that look
  6. Call display.display() once. Don't call it twice
void drawOpenEye(int cx, int cy, int lookX, int lookY) {
  // sclera
  display.fillCircle(cx, cy, EYE_RX, SSD1306_WHITE);
  // keep pupil inside — clamp look offsets
  int px = constrain(lookX, -8, 8);
  int py = constrain(lookY, -4, 4);
  display.fillCircle(cx + px, cy + py, PUPIL_R, SSD1306_BLACK);
  // highlight
  display.fillCircle(cx + px - 2, cy + py - 2, 2, SSD1306_WHITE);
}

If your module looks "fat" because of a circular fill overlapping lids, switch to drawRoundRect + fillRoundRect for a more anime "stadium" eye. You keep the same pupil math.

Look left / right without blocking

Humans don't stare forever. Idle life is simple. You hold center a bit, glance, hold, glance the other way, and blink now and then. Store your intent in variables, not in nested delay() sandwiches.

enum LookDir : int8_t { LOOK_LEFT = -1, LOOK_CENTER = 0, LOOK_RIGHT = 1 };

LookDir look = LOOK_CENTER;
int8_t lookX = 0;                 // animated pixel offset
unsigned long nextLookAt = 0;

void updateLook(unsigned long now) {
  if (now < nextLookAt) return;
  // pick a new target every 1.2–2.8 s
  uint8_t r = random(0, 3);
  look = (r == 0) ? LOOK_LEFT : (r == 1) ? LOOK_RIGHT : LOOK_CENTER;
  nextLookAt = now + 1200UL + random(0, 1600);
}

// ease pupil toward target each frame
void easePupil() {
  int target = (int)look * 7;
  if (lookX < target) lookX++;
  else if (lookX > target) lookX--;
}

Keep easePupil() light, and change by one pixel per redraw. If you call redraw at 20-30 Hz, it already looks smooth on OLED because black-to-white edges are sharp. Don't chase 60 fps. You'll lose, because I2C bandwidth and display() time will fight you, especially on long Dupont wires.

Blink frames (the bit that sells the illusion)

A convincing blink is three to five discrete shapes, not one "line then open." Here's my workshop set:

  1. Open, full sclera + pupil, the way you start
  2. Half, black bars (lids) cover the top and bottom thirds
  3. Closed, thin white horizontal line where the eye was
  4. Half again on the way up
  5. Open
enum BlinkPhase : uint8_t {
  BLINK_IDLE = 0,
  BLINK_CLOSING,
  BLINK_CLOSED,
  BLINK_OPENING
};

BlinkPhase blink = BLINK_IDLE;
uint8_t blinkStep = 0;            // 0 open .. 4 closed-ish scale
unsigned long nextBlinkAt = 0;
unsigned long blinkStepAt = 0;

void startBlink(unsigned long now) {
  if (blink != BLINK_IDLE) return;
  blink = BLINK_CLOSING;
  blinkStep = 0;
  blinkStepAt = now;
}

void updateBlink(unsigned long now) {
  if (blink == BLINK_IDLE) {
    if (now >= nextBlinkAt) {
      startBlink(now);
      nextBlinkAt = now + 2800UL + random(0, 4000);
    }
    return;
  }

  // advance lid every ~35 ms
  if (now - blinkStepAt < 35) return;
  blinkStepAt = now;

  if (blink == BLINK_CLOSING) {
    if (blinkStep < 4) blinkStep++;
    else { blink = BLINK_CLOSED; }
  } else if (blink == BLINK_CLOSED) {
    blink = BLINK_OPENING;
  } else if (blink == BLINK_OPENING) {
    if (blinkStep > 0) blinkStep--;
    else blink = BLINK_IDLE;
  }
}

// 0 = fully open, 4 = fully closed
void drawEyeWithBlink(int cx, int cy, int lookX, int lookY, uint8_t step) {
  if (step >= 4) {
    display.drawFastHLine(cx - EYE_RX, cy, EYE_RX * 2, SSD1306_WHITE);
    return;
  }
  display.fillCircle(cx, cy, EYE_RX, SSD1306_WHITE);
  // lid cover from top and bottom based on step
  int cover = step * 5; // pixels of black lid
  display.fillRect(cx - EYE_RX, cy - EYE_RX, EYE_RX * 2, cover, SSD1306_BLACK);
  display.fillRect(cx - EYE_RX, cy + EYE_RX - cover, EYE_RX * 2, cover, SSD1306_BLACK);
  if (step < 3) {
    int px = constrain(lookX, -8, 8);
    int py = constrain(lookY, -4, 4);
    display.fillCircle(cx + px, cy + py, PUPIL_R, SSD1306_BLACK);
  }
}

Randomize your idle blink interval so the face never feels like a metronome. Double blinks (two closures a few hundred ms apart) are an easy next step if you want more personality. Just schedule a second startBlink() during BLINK_IDLE shortly after the first finishes.

Emotion states: happy and sleepy

I keep emotions as an enum and let draw code branch lightly. Happy lowers the lower lid into a soft curve. You can fake a curve with a black filled arc (triangle wedges) or simply raise a thick black band under the pupil so the eye looks squinting with joy. Sleepy drops both lids permanently (you start from step 2) and slows the blink + look timers.

enum Mood : uint8_t { MOOD_NORMAL, MOOD_HAPPY, MOOD_SLEEPY };
Mood mood = MOOD_NORMAL;

void applyMoodOverlay(int cx, int cy) {
  if (mood == MOOD_HAPPY) {
    // soft smile lids: cover lower portion
    display.fillRect(cx - EYE_RX, cy + 4, EYE_RX * 2, EYE_RX, SSD1306_BLACK);
    // little upward curve using two lines
    display.drawLine(cx - 10, cy + 6, cx, cy + 2, SSD1306_WHITE);
    display.drawLine(cx, cy + 2, cx + 10, cy + 6, SSD1306_WHITE);
  } else if (mood == MOOD_SLEEPY) {
    // heavy upper lid
    display.fillRect(cx - EYE_RX, cy - EYE_RX, EYE_RX * 2, 10, SSD1306_BLACK);
  }
}

Drive the mood from real inputs when you can: light sensor → sleepy in the dark, Ultrasonic "someone close" → happy look toward the object, battery low → half lids. Your eyes become the UI for the robot's state, which is more useful than a seven-segment percent.

Frame rate and redraw strategy

You should redraw only when something visible changed (look offset, blink step, mood) or on a slow idle tick so you still clear noise. That's all you need. A fixed 40 ms redraw (~25 Hz) is plenty for you:

unsigned long lastDraw = 0;
const unsigned long FRAME_MS = 40;

void loop() {
  unsigned long now = millis();
  updateLook(now);
  updateBlink(now);
  easePupil();
  // optional: read sensors / buttons here

  if (now - lastDraw >= FRAME_MS) {
    lastDraw = now;
    display.clearDisplay();
    uint8_t step = (blink == BLINK_IDLE) ? 0 : blinkStep;
    if (mood == MOOD_SLEEPY && step < 2) step = 2;
    drawEyeWithBlink(LEFT_CX, EYE_CY, lookX, 0, step);
    applyMoodOverlay(LEFT_CX, EYE_CY);
    drawEyeWithBlink(RIGHT_CX, EYE_CY, lookX, 0, step);
    applyMoodOverlay(RIGHT_CX, EYE_CY);
    display.display();
  }
}

You'll notice both eyes share lookX. That's intentional, since human eyes conjugate, and yours do too. For a lazy comedy robot you can offset the right eye by a couple of pixels so they never quite agree.

Optional second OLED for dual eyes

Chassis builders love one display per eye, and I get why. You'll need two addresses, so change the solder jumper on one module to 0x3D, then instantiate two displays. You'll find full dual wiring notes in the dual OLED article. The eye logic stays the same, so you call the same drawEyeWithBlink once per panel with center coordinates local to that 128×64 (for example cx = 64 on each).

Adafruit_SSD1306 leftEye(128, 64, &Wire, -1);
Adafruit_SSD1306 rightEye(128, 64, &Wire, -1);

void setup() {
  if (!leftEye.begin(SSD1306_SWITCHCAPVCC, 0x3C)) for (;;);
  if (!rightEye.begin(SSD1306_SWITCHCAPVCC, 0x3D)) for (;;);
}

Warning for your Uno: two full Adafruit buffers are ~2 KB of SRAM before your sketch variables. That often still fits a lean eyes sketch, but any extra sensors + String use will push you over. I'd go for ESP32, or one panel with both eyes drawn, once you or your students start adding Wi-Fi libraries.

Memory tips from my lab

  • Keep your strings in F() if you print debug text on the OLED.
  • Don't stack many full-screen PROGMEM frames "just in case."
  • If you export blink bitmaps from a tool, crop them to the eye bounding box (e.g. 48×40), not 128×64.
  • Don't create temporary Adafruit_SSD1306 objects inside loop(). You'll run out of RAM fast.
  • Read the Uno frame budget guide before you pack a 20-frame welcome animation onto the same board.
OLED Animation Maker templates tab with eyes, icons and UI animations ready to preview on an SSD1306

Refining frames in OLED Animation Maker

Once your timing state machine works, polish the shapes visually. Open oledanimationmaker.com, draw a closed lid and a half lid as small sprite frames, export Adafruit PROGMEM arrays, and swap the "closed" / "half" branches to drawBitmap. Leave look offsets as live math. If you combine bitmap lids with a moving pupil, you get what makes store-shelf toys feel custom without burning the entire flash chip, and you can do the same.

For brand eyes (hexagonal lenses, LED-ring pupils), draw once in the maker, export, then keep your millis() scheduler unchanged. The scheduler's the hard part, and you can iterate on pixels.

Full sketch (copy-paste)

It's a single 128×64 panel with both eyes, and look, blink and moods cycle for the demo. You get an optional blink button on D2 (INPUT_PULLUP). Libraries: Adafruit GFX + Adafruit SSD1306.

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

Adafruit_SSD1306 display(128, 64, &Wire, -1);

const int LEFT_CX = 40;
const int RIGHT_CX = 88;
const int EYE_CY = 32;
const int EYE_RX = 22;
const int PUPIL_R = 6;
const uint8_t PIN_BLINK = 2;

enum LookDir : int8_t { LOOK_LEFT = -1, LOOK_CENTER = 0, LOOK_RIGHT = 1 };
enum BlinkPhase : uint8_t { BLINK_IDLE, BLINK_CLOSING, BLINK_CLOSED, BLINK_OPENING };
enum Mood : uint8_t { MOOD_NORMAL, MOOD_HAPPY, MOOD_SLEEPY };

LookDir look = LOOK_CENTER;
int8_t lookX = 0;
BlinkPhase blink = BLINK_IDLE;
uint8_t blinkStep = 0;
Mood mood = MOOD_NORMAL;

unsigned long nextLookAt = 0;
unsigned long nextBlinkAt = 0;
unsigned long blinkStepAt = 0;
unsigned long nextMoodAt = 0;
unsigned long lastDraw = 0;

bool btnLast = true;

void startBlink(unsigned long now) {
  if (blink != BLINK_IDLE) return;
  blink = BLINK_CLOSING;
  blinkStep = 0;
  blinkStepAt = now;
}

void updateLook(unsigned long now) {
  if (now < nextLookAt) return;
  uint8_t r = random(0, 3);
  look = (r == 0) ? LOOK_LEFT : (r == 1) ? LOOK_RIGHT : LOOK_CENTER;
  unsigned long span = (mood == MOOD_SLEEPY) ? 2200UL : 1200UL;
  nextLookAt = now + span + random(0, 1600);
}

void easePupil() {
  int target = (int)look * 7;
  if (lookX < target) lookX++;
  else if (lookX > target) lookX--;
}

void updateBlink(unsigned long now) {
  if (blink == BLINK_IDLE) {
    if (now >= nextBlinkAt) {
      startBlink(now);
      unsigned long gap = (mood == MOOD_SLEEPY) ? 4500UL : 2800UL;
      nextBlinkAt = now + gap + random(0, 4000);
    }
    return;
  }
  unsigned long pace = (mood == MOOD_SLEEPY) ? 55UL : 35UL;
  if (now - blinkStepAt < pace) return;
  blinkStepAt = now;
  if (blink == BLINK_CLOSING) {
    if (blinkStep < 4) blinkStep++;
    else blink = BLINK_CLOSED;
  } else if (blink == BLINK_CLOSED) {
    blink = BLINK_OPENING;
  } else if (blink == BLINK_OPENING) {
    if (blinkStep > 0) blinkStep--;
    else blink = BLINK_IDLE;
  }
}

void applyMoodOverlay(int cx, int cy) {
  if (mood == MOOD_HAPPY) {
    display.fillRect(cx - EYE_RX, cy + 4, EYE_RX * 2, EYE_RX, SSD1306_BLACK);
    display.drawLine(cx - 10, cy + 6, cx, cy + 2, SSD1306_WHITE);
    display.drawLine(cx, cy + 2, cx + 10, cy + 6, SSD1306_WHITE);
  } else if (mood == MOOD_SLEEPY) {
    display.fillRect(cx - EYE_RX, cy - EYE_RX, EYE_RX * 2, 10, SSD1306_BLACK);
  }
}

void drawEyeWithBlink(int cx, int cy, int lx, uint8_t step) {
  if (step >= 4) {
    display.drawFastHLine(cx - EYE_RX, cy, EYE_RX * 2, SSD1306_WHITE);
    return;
  }
  display.fillCircle(cx, cy, EYE_RX, SSD1306_WHITE);
  int cover = step * 5;
  display.fillRect(cx - EYE_RX, cy - EYE_RX, EYE_RX * 2, cover, SSD1306_BLACK);
  display.fillRect(cx - EYE_RX, cy + EYE_RX - cover, EYE_RX * 2, cover, SSD1306_BLACK);
  if (step < 3) {
    int px = constrain(lx, -8, 8);
    display.fillCircle(cx + px, cy, PUPIL_R, SSD1306_BLACK);
    display.fillCircle(cx + px - 2, cy - 2, 2, SSD1306_WHITE);
  }
}

void pollBlinkButton(unsigned long now) {
  bool raw = digitalRead(PIN_BLINK); // HIGH = not pressed
  if (btnLast == HIGH && raw == LOW) startBlink(now);
  btnLast = raw;
}

void setup() {
  pinMode(PIN_BLINK, INPUT_PULLUP);
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) for (;;);
  randomSeed(analogRead(A0));
  unsigned long now = millis();
  nextLookAt = now + 800;
  nextBlinkAt = now + 1500;
  nextMoodAt = now + 8000;
  display.clearDisplay();
  display.display();
}

void loop() {
  unsigned long now = millis();
  pollBlinkButton(now);
  updateLook(now);
  updateBlink(now);
  easePupil();

  if (now >= nextMoodAt) {
    mood = (Mood)((mood + 1) % 3);
    nextMoodAt = now + 10000UL;
  }

  if (now - lastDraw >= 40) {
    lastDraw = now;
    display.clearDisplay();
    uint8_t step = (blink == BLINK_IDLE) ? 0 : blinkStep;
    if (mood == MOOD_SLEEPY && blink == BLINK_IDLE && step < 2) step = 2;
    drawEyeWithBlink(LEFT_CX, EYE_CY, lookX, step);
    applyMoodOverlay(LEFT_CX, EYE_CY);
    drawEyeWithBlink(RIGHT_CX, EYE_CY, lookX, step);
    applyMoodOverlay(RIGHT_CX, EYE_CY);
    display.display();
  }
}

Tuning on your robot

  • Your eyes are too big / overlapping: lower EYE_RX or move your centers farther apart.
  • Your pupils clip outside the white: tighten your constrain limits or shrink PUPIL_R.
  • Blink looks harsh: add more steps (0..6) and a longer pace. That'll soften it.
  • Your face feels nervous: lengthen your look hold times, and reduce how often look is non-center.
  • You want sound sync: call startBlink() when your servo moves or a speaker beep starts.

Making your look direction mean something

Random glances are fine for a desk mascot. On a mobile robot I wire look to the same sensors that already drive motion, and I'd suggest you do too. Example: if an HC-SR04 reading on the left is closer than the right by more than 8 cm, force look = LOOK_LEFT for at least half a second before you return to idle wander. Students instantly get "the robot noticed the obstacle" without a text HUD.

For a pan-tilt camera head, map your servo angles to pupil offsets with a linear scale. Keep the range small (±6 to ±8 px), or the pupil escapes the sclera and the character looks broken. When the head's moving quickly, suppress your random look changes. Competing motions make the face feel drunk rather than curious.

A button or capacitive touch near the chin can trigger happy mood for a few seconds. That single affordance turns your OLED into a social interface, which is exactly why you'll see people bolt screens onto otherwise boring chassis.

Power, flicker, and motors on the same rail

OLED eyes look great until a motor driver browns out your 5V rail. Here are symptoms you might mislabel as "animation bugs": a sudden full blank, stuck frames, or pupils that freeze mid-glance. I separate motor power, keep a fat electrolytic near the OLED VCC, and shorten I2C wires before I touch the blink timing again. You should try that first too.

If you must share USB power for a demo, throttle your servo motion while display() is in flight, or simply accept 15 FPS and fewer simultaneous actuators. Classroom robots that "worked on the bench" often fail on the competition carpet for this reason alone, and it's easy to miss.

From your demo to a reusable module

Once you like the behavior, lift your eyes into a small C++ class or a pair of .h/.cpp files, like this: begin(), setMood(), nudgeLook(), update(now), draw(display). Keep your Arduino loop() thin. That structure survives when you later bolt on a menu system or a battery meter on the same panel. eyes become one layer you redraw after the HUD, or you swap to a dedicated eye OLED and leave telemetry on the other.

Troubleshooting FAQ

My eyes draw but never blink

Check that your updateBlink runs every loop and that nextBlinkAt isn't stuck in the past incorrectly. Also confirm you aren't blocking with a long delay() elsewhere in your sketch. It's the usual culprit.

One eye lags the other on my dual OLEDs

You're probably calling display() on the left, doing heavy work, then calling it on the right. Update both buffers, then flush both back-to-back. Keep your I2C wires short, and share a solid GND between the two. I'd check that first.

Allocation failed when I add a second display

You've run out of SRAM. You can stay with one panel drawing two eyes, move to ESP32, or switch to a page-buffer library for advanced cases. See the library comparison post.

Can I use bitmaps instead of fillCircle in my sketch?

Yes, you can. Export open / half / closed frames from the maker and select by blinkStep. Keep your pupil as a live fill so look direction stays free.

I have an SH1106 module and my eyes look shifted

It's a classic controller mismatch. You'll want an SH1106-capable init, or you can add a small X offset. You'll find details in SH1106 vs SSD1306.

One of my eyes blinks and the other stays open

Here's how a wink works: you pass a non-zero lid step into only one drawEyeWithBlink call. If both calls share the same step variable, you'll get a normal blink. If the idle eye accidentally receives blinkStep while the phase is closing, both of your lids move. Pass 0 for the eye that should stay open. That's the fix.

My pupils jitter when I aim them with a potentiometer

A raw analogRead on a loose breadboard wiggles by several counts, and you'll see that as a pixel. Average four samples, or move the pupil only when the reading changes by more than about 8 counts. Your blink timer isn't the source of that shake.

My blink feels sleepy even with the random timer shortened

The gap between blinks and the lid travel are different clocks, so you have to tune them apart. If you close in four steps at 35 ms, then hold, then open, that's roughly a third of a second of lid motion. Shorten the per-step wait toward 15 ms if you want a snappier blink. Leave the 2.8 s idle gap alone.

A wink, and a knob that aims the pupils

The main loop blinks both eyes together, which reads as alive and never as a reaction. A wink is the same state machine with one extra argument: which eye you let close. Add a winkLeft flag. When a button on D2 fires a wink, you set the flag, call startBlink(), and in the draw section pass step to the left eye only. That's all you need. The right call gets 0 so its lid stays open and its pupil still eases. You clear the flag when the phase returns to BLINK_IDLE. If you forget that clear, every later blink stays one-eyed, and it'll look broken rather than playful.

Lid speed is the 35 ms step you've already got in updateBlink, not the 40 ms redraw. Four closing steps, one held closed step, and four opening steps land near 9 × 35 ms, about 300 ms of travel, while your glass may repaint every 40 ms. People read a casual blink as shorter than that. You'll often see the 100-150 ms range for the closed part of the gesture. You don't need new art to get there. Drop your step interval toward 15 ms and keep the idle gap (about 2.8 s plus a random few seconds) so the face doesn't flutter. The table is a starting map for that one constant, and you can tune from it.

Step intervalApprox. close + hold + openHow it reads
15 ms~140 msA snappy wink or blink for you
25 ms~230 msRelaxed character
35 ms (sketch default)~300 msSlightly sleepy if you use it for every blink
50 ms~450 msUse it for the sleepy mood only

Aiming is the second behavior that the random look states don't cover. I'd park a 10k potentiometer on A1, with its ends to 5V and GND and its wiper to A1. Map the 0-1023 reading into the same pupil limits you already constrain, something like map(sample, 0, 1023, -6, 6), and write that into lookX while a "manual aim" flag is set. You should average four analogRead calls. If you don't, the pupil chatters on a noisy Uno pin and you'll "fix" it by slowing the blink. When the flag's clear, your existing wander runs. On ESP32 you'd use an ADC pin that isn't GPIO21 or GPIO22. Those two stay SDA and SCL for your SSD1306 at 0x3C. ESP8266 boards label the OLED as D2 and D1, so put your knob on A0, which is the one easy analog input.

Draw order still matters with a wink. Update your blink phase, ease the pupil, then clear once, draw both eyes, and call display() once per 40 ms tick. If you add a second display() for the winking eye, you double a 1024-byte transfer and make that eye lag the open one. If your knob and a servo share the 5V pin, a moving servo can still blank the panel. That rail problem is separate from the wink flag. Prove the wink on USB power with your servo unplugged, then add the motor supply back.

Related

Skip the code: design your eyes in the browser

The free OLED Robot Eyes generator lets you pick moods, blinking and look-around, previews them on a virtual 128x64 OLED, and exports a ready-to-upload Arduino, ESP32 or MicroPython sketch.

Open the Robot Eyes generator →

Polish your lids as bitmap frames

Sketch your custom closed and half-open lids in the free tool, export PROGMEM arrays, and drop them into this blink state machine.

Open oledanimationmaker.com →

Free tools: OLED Animation Maker for SSD1306 and SH1106 animations, Assemble Studio for name and logo animations, the Shadow Box Lamp Generator for 3D-printed shadow lamps, Text to STL for 3D-printed names and keychains, and 3MF to Web to show 3D prints on any website. New: the Image to Byte Array converter, the OLED Robot Eyes generator and the Lithophane Maker. See all tools.