OLED Sketch Simulator — paste an Arduino or bare-metal C sketch to preview on a simulated display

How It Works

Paste a full .ino, .c, or .cpp file into the text area — or use the file picker to load one from disk. Click ▶ Run Sketch and the simulator will parse the source, extract array definitions and function bodies, then replay every draw call against a virtual framebuffer. The result is rendered on the canvas below at the selected zoom level. No compilation takes place: the simulator pattern-matches known API calls and redraws them in JavaScript.

If the library is not detected automatically from the source (for example, a bare sketch with no recognizable constructor), the Fallback display size chosen in the toolbar is used to set the canvas dimensions. To generate ready-to-run example sketches in any of the supported formats, use the Bitmap File Viewer and Editor.

CategorySimulated — Phase 1Not yet simulated — Phase 2
Pixels & geometry drawPixel, drawLine, drawFastHLine, drawFastVLine, drawRect, fillRect, drawCircle, fillCircle, drawRoundRect, fillRoundRect, drawTriangle, fillScreen, clearDisplay / clearBuffer
Bitmaps drawBitmap (H-MSB — Adafruit), drawXBMP / drawXBM (H-LSB — u8g2), oledDrawBitmap / sh1106_draw_bitmap_pgm (V-LSB page mode)
Text & fonts setFont, setTextSize, setTextColor, setCursor, print, println, drawStr, drawChar
Hardware / I—O silently ignored delay, Wire, SPI, Serial, GPIO
Control flow if / else, for loops, while loops (up to 64 iterations), user-defined helper functions Infinite while(1) in loop() — only code before it runs

Supported Libraries

Adafruit SSD1306 / SH1106

Detected from Adafruit_SSD1306, Adafruit_SH1106, or Adafruit_SH110 in the source. Display size is read from the constructor call. Supports all Adafruit_GFX geometry primitives and drawBitmap() with horizontal MSB byte layout.

u8g2

Detected from a U8G2_ constructor. Display size is parsed from the constructor name, e.g. U8G2_SSD1306_128X64. Supports drawXBMP, drawFrame, drawBox, drawHLine, drawVLine, drawDisc, drawRFrame, drawRBox, and clearBuffer / sendBuffer.

Bare-metal AVR C / Direct I2C

Detected from sh1106_ function prefixes, SH1106_WIDTH, or oledDrawBitmap / oledInit. Supports sh1106_draw_bitmap_pgm, sh1106_fill_rect, sh1106_set_pixel, oledDrawBitmap, and the clear / fill / flush helpers. User-defined drawing functions (build_splash(), drawSplash(), etc.) are called automatically.

Tips

  • The simulator runs setup() first, then one pass of loop(). For bare-metal .c files it runs main() instead.
  • User-defined helper functions (e.g. drawSplash(), build_splash()) are resolved and executed automatically when called from setup() or loop().
  • Variable declarations and arithmetic expressions are evaluated, so centering math like (SCREEN_WIDTH - BMP_W) / 2 produces the correct pixel coordinates.
  • #define constants are extracted and resolved. SCREEN_WIDTH, SCREEN_HEIGHT, BMP_W, BMP_H, WHITE, BLACK, and SH1106_WIDTH / SH1106_HEIGHT are pre-seeded.
  • If the bitmap appears garbled or off-center, check that the byte layout in the sketch matches what the simulator expects for that library: H-MSB for Adafruit, H-LSB for u8g2, V-LSB for direct / bare-metal.
  • After running a sketch, changing the Zoom selector immediately re-renders the last result without re-parsing.