// ← back to all

happy_face

// happy_face · by 0x1306 · 4 frames · 100ms · emoji
// views · runs
// preview
frame_00 / 04// 100ms per frame
// space: play/pause · ←→: step frames
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
#include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> // 0x1306.dev · animation: happy_face · 4 frames · 100ms #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 #define SCREEN_ADDRESS 0x3C Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); #define FRAME_COUNT 4 #define FRAME_DELAY 100 void drawFrame(int frame) { display.clearDisplay(); int cx = 64; int cy = 32; // --- face outlines --- display.drawCircle(cx, cy, 26, WHITE); // --- eyes --- draw AFTER face, BEFORE smile mask --- if (frame == 3) { // blink display.drawFastHLine(cx - 13, cy - 8, 9, WHITE); display.drawFastHLine(cx + 4, cy - 8, 9, WHITE); } else { // open display.fillRect(cx - 13, cy - 11, 6, 6, WHITE); display.fillRect(cx + 7, cy - 11, 6, 6, WHITE); } // --- smile --- bottom arc 200 to 340 degrees --- for (int a = 200; a < 340; a += 8) { float rad = a * 0.0174533; int x = cx + 15 * cos(rad); int y = cy + 15 * sin(rad); display.drawPixel(x, y, WHITE); } display.display(); } void setup() { Wire.begin(21, 22); // SDA=21, SCL=22 for ESP32 DevKit // change to 0x3D if display not found display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS); display.clearDisplay(); display.display(); } void loop() { for (int i = 0; i < FRAME_COUNT; i++) { drawFrame(i); delay(FRAME_DELAY); } }
// share
// embed
// paste into any html · 320×200 · transparent click opens detail page