// ← back to all

eyes_happy

// eyes_happy · by 0x1306 · 4 frames · 100ms · robot_eyes
// views · runs
// preview
frame_00 / 04// 100ms per frame
// space: play/pause · ←→: step frames
12345678910111213141516171819202122232425262728293031323334353637383940
#include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> // 0x1306.dev · animation: eyes_happy · robot_eyes · 100ms #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); void drawEyes(int lx, int ly, int lw, int lh, int lr, int rx, int ry, int rw, int rh, int rr) { display.fillRoundRect(lx - lw/2, ly - lh/2, lw, lh, lr, WHITE); display.fillRoundRect(rx - rw/2, ry - rh/2, rw, rh, rr, WHITE); } void drawFrame(int frame) { display.clearDisplay(); int h[] = {28, 24, 18, 24}; int y[] = {32, 34, 37, 34}; drawEyes(32, y[frame], 38, h[frame], 8, 96, y[frame], 38, h[frame], 8); if (h[frame] < 28) { int flatten = (28 - h[frame]) / 2; display.fillRect(32-19, y[frame]-h[frame]/2, 38, flatten, BLACK); display.fillRect(96-19, y[frame]-h[frame]/2, 38, flatten, BLACK); } display.display(); } void setup() { Wire.begin(21, 22); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); } void loop() { for (int i = 0; i < 4; i++) { drawFrame(i); delay(100); } }
// share
// embed
// paste into any html · 320×200 · transparent click opens detail page