// ← back to all

train_moving

// train_moving · by 0x1306 · 8 frames · 67ms · indian
// views · runs
// preview
frame_00 / 08// 67ms per frame
// space: play/pause · ←→: step frames
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
#include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> // 0x1306.dev · animation: train_moving · 8 frames · 67ms #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 8 #define FRAME_DELAY 67 void drawFrame(int frame) { display.clearDisplay(); int cx = 64; int cy = 38; // Motion offset mapping int offset = -((int)(frame * 3.2)) % 32; // --- track --- display.drawFastHLine(0, cy + 6, 128, WHITE); for (int i = 0; i < 3; i++) { int carX = cx + (i * 25) + offset; // box display.fillRect(carX, cy - 15, 22, 18, WHITE); display.fillRect(carX + 5, cy - 10, 6, 6, BLACK); display.fillRect(carX + 15, cy - 10, 6, 6, BLACK); // connectors if (i < 2) { display.fillRect(carX + 22, cy - 2, 3, 2, WHITE); } // wheels display.fillCircle(carX + 5, cy + 3, 2, WHITE); display.fillCircle(carX + 17, cy + 3, 2, 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