OLED Robot Eyes Generator

Pick a mood, shape the eyes, and watch them blink on a pixel-exact OLED preview. The code below the controls redraws the same eyes on your board, with no bitmaps to store.

Display

Eye shape

Presets:

Behaviour

Mood sequence

Each step holds a mood for the time you set, then the eyes ease into the next one.

Interaction (optional)

Serial: send 0 to 8 for a mood, r to resume, b to blink. A TTP223 touch pad makes the eyes happy for two seconds.

Get the code

Robot eyes settings explained

Everything you change above is turned into a handful of numbers in the generated code, so what you see in the preview is exactly what your board draws. These notes explain what each group of settings does and suggest starting points for popular robot styles.

Starting points for common robot faces

StyleWidth × HeightCorner radiusGapExtras
EMO / Cozmo-style desk robot36 × 368 to 1014No pupils, breathing bob on
Tall pill eyes22 × 4411 (half the width)20Look range up/down 4 or less
Wide visor50 × 1648Works well on 128×32 bar screens
Cute cartoon eyes30 × 341416Pupils on, pupil size 6 to 8
Cyclops robot48 × 4012n/aOne eye on, larger pupil

The four preset buttons above load similar values in one click, so it is often quickest to start from a preset and adjust.

Eye shape

Width and Height are in screen pixels on a 128×64 display. Keep two eyes plus the gap under about 110 pixels wide, or they will clip at the edges when the eyes look left and right. Corner radius turns a rectangle into a rounded box; set it to half the smaller side for a pill or circle. Vertical position moves both eyes up or down, which is useful when the top rows of a yellow and blue split screen are a different colour.

Moods and sequences

There are nine moods: Neutral, Happy, Angry, Sad / tired, Surprised, Suspicious, Sleepy, Love and Confused. Each one is drawn by cutting eyelids into the basic eye shape, so changing the shape changes every mood with it. A mood sequence plays moods in order, each held for its own time, and the eyes ease from one to the next rather than jumping. A good idle loop is Neutral for 6 seconds, Suspicious for 2, Neutral again, then Sleepy for 3.

Behaviour

Which code to pick

Procedural code draws the eyes with shapes every frame. It is tiny, fits an Arduino Uno, and can switch mood at any time from your own code, which is why it is the default. Bitmap frames export each frame as an image instead; use them only when you need a fixed animation and have plenty of flash, such as on an ESP32. Choose Adafruit GFX if you already use that library, U8g2 for SH1106 1.3 inch screens and lower RAM use, or MicroPython for Raspberry Pi Pico and ESP32 boards running Python.

Controlling the eyes from your project

With Serial control on, open the Serial Monitor at 115200 baud and send a number from 0 to 8 to pick a mood, b to blink or r to resume the sequence. A TTP223 touch pad on the pin you enter makes the robot happy for two seconds when it is touched. The same mood numbers can be set from sensors, for example Surprised when an ultrasonic sensor sees something close, or Sleepy after a minute without movement.