Every workshop I run, someone hits the same wall. The animation looks fine in the browser, the sketch compiles, then the Arduino IDE says the sketch is too big. Or worse, it uploads, and then your board resets in a loop because RAM ran out.
This post is the math I write on the whiteboard. There's no marketing fluff, just how many 128×64 OLED frames you can actually store on an Arduino Uno, and what you should do when you need more.
The hard numbers for your Uno
- Flash: 32 KB total. The bootloader usually keeps ~0.5 KB, so you get roughly 31.5 KB for code and data.
- SRAM: 2 KB. The Adafruit SSD1306 buffer alone takes 1024 bytes of that for 128×64, so you've only got half left.
- One full-frame bitmap: 128 × 64 ÷ 8 = 1024 bytes (1 KB), and you'll pay that for every frame.
So each full-screen frame costs about 1 KB of flash if you store it in PROGMEM. Leave that array in regular RAM and you're nearly out of SRAM before your own variables even start.
How many frames will you fit in practice?
Your sketch isn't only bitmaps. Adafruit GFX, SSD1306, Wire and your own loop() easily eat
10-14 KB of flash on a typical animation sketch. That leaves you roughly
16-20 KB for frames.
| Frame size | Bytes / frame | Realistic max on Uno* |
|---|---|---|
| 128×64 full screen | 1024 | ~12-18 frames |
| 64×64 sprite | 512 | ~24-36 frames |
| 32×32 icon | 128 | ~80-120 frames |
| 128×32 banner | 512 | ~24-36 frames |
*That's after libraries. Always check the IDE compile bar. "Sketch uses X bytes" is the truth, and my estimate isn't.
Store your frames in PROGMEM (it's required)
If you forget PROGMEM, the compiler may put the array in SRAM. On Uno that often means
instant crashes or weird resets. Here's the pattern that works:
#include <avr/pgmspace.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// 1 KB frame — lives in flash, not the 2 KB SRAM
const uint8_t frame0[] PROGMEM = {
// 1024 bytes from your converter…
0x00, 0x00 /* … */
};
const uint8_t* const frames[] PROGMEM = { frame0 /*, frame1, … */ };
const uint8_t FRAME_COUNT = 1;
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}
void loop() {
static uint8_t i = 0;
display.clearDisplay();
// pgm_read_word because frames[] itself is in PROGMEM on AVR
const uint8_t* f = (const uint8_t*)pgm_read_word(&frames[i]);
display.drawBitmap(0, 0, f, 128, 64, SSD1306_WHITE);
display.display();
i = (i + 1) % FRAME_COUNT;
delay(80);
}
On ESP32 or SAMD you often don't need the pgm_read_word dance the same way, but on an Uno you do.
If your image looks like garbage, check that first.
What actually ate my students' flash in class projects
- Too many full-screen frames. A 24-frame walk cycle at 128×64 is ~24 KB of bitmaps alone. Your Uno can't take that plus libraries.
- Serial debug left on. Extra strings and
Serial.printadd up. They're fine for debugging, but strip them for your final upload. - Unused library features. If you pull in huge font sets or multiple display drivers, you waste space.
- Duplicating similar frames. Blink animations often only need 2-4 frames. Exporting 20 "almost the same" frames is the number one student mistake I see.
Tricks that actually help you on an Uno
1. Use smaller sprites, not full-screen every frame
Draw a static background with GFX (drawRect, text), and animate only a 32×32 or 48×48 sprite.
Your memory use drops fast. The free tool's shape export helps here, because vector-style GFX code is tiny
compared with bitmaps.
2. Shorter loops you can fit
A 6-frame loop at 10 FPS looks smoother than a 20-frame loop you can't fit. Cut the frames that don't change much.
3. Try a 128×32 display
Half the pixels means half the bytes per frame. If your project only needs a status strip, buy a 128×32 and you've suddenly got room again.
4. Move up when you outgrow Uno
The Nano Every, Mega and especially ESP32 change the game. You'll measure ESP32 flash in megabytes. If your animation needs 40+ full frames, stop fighting the Uno and change the board.
How I check before I upload
- Export your animation, then look at frame count × 1024.
- Add ~12 KB for a typical Adafruit sketch.
- If the total is over ~28 KB, cut frames or shrink sprites before you paste into the IDE.
- After compile, read "Global variables use X bytes of dynamic memory." If SRAM use is over ~1500 bytes, you're in the danger zone on an Uno.
Quick FAQ for you
Why does the IDE say my sketch fits but my board resets?
Your flash was fine, but your SRAM wasn't. Usually the bitmap isn't in PROGMEM, or you've created a second full display buffer somehow.
Can I stream my frames from an SD card?
Yes, but SD and file parsing on an Uno is slow and fiddly for beginners. For class projects I'd still rather use fewer PROGMEM frames or an ESP32.
Does MicroPython on a Pico have the same limit for me?
No, a Pico has far more RAM and flash. It's a different platform with a different budget. This article is only about the classic AVR Uno and Nano.
Long clips that won't ever fit: 150 to 200 frames
The table above is the workshop range: a dozen or so full 128×64 frames on an Uno after Adafruit is linked. The song and festival sketches on this site sit far outside that range. I use them as a ruler, because the frame counts are real and the byte math is the same 1024 bytes per picture.
| Loop | Frames | Bitmap flash | Stock delay | Uno? |
|---|---|---|---|---|
| Khayalon Ki Duniya | 124 | ~124 KB | 67 ms (~15 fps) | No |
| Kalayani | 148 | ~148 KB | 318 ms (~3 fps) | No |
| Ganesha Day 7 | 150 | ~150 KB | 67 ms (~15 fps) | No |
| Nazarome Chupale | 150 | ~150 KB | 147 ms (~6.8 fps) | No |
| Thangamaana | 200 | ~200 KB | 149 ms (~6.7 fps) | No |
If you slow the delay, you don't move a row into the Uno column. A 318 ms Kalayani step and
a 67 ms Ganesha step cost the same flash. Timing lives in one integer in
loop(). The bitmaps live in PROGMEM arrays whether you show
them quickly or not. If the IDE says your sketch is too big, open the frame list, not
the delay.
Those loops are also why "it compiled on my ESP" isn't a mystery. An ESP32, or an ESP8266 module set to 4MB flash, has room for a 200 KB table plus GFX. A classic Uno doesn't, and a classic Nano is the same ATmega328P with the same 32 KB. Nano Every and Nano ESP32 are different products. Read the silk and the board menu before you apply this article's ceiling to them, because they aren't the same.
What the video importer does to your budget
The video-to-OLED path samples your clip at about 15 frames per second and stops at 200 frames. That ceiling is about 200 KB of 128×64 bitmaps, the same size as the Thangamaana sketch. A four-second clip lands near 60 frames (about 60 KB). An eight-second clip lands near 120 frames (about 120 KB). Both are normal ESP exports, and you can't run either on an Uno once libraries take 10-14 KB.
If the only board in the room is an Uno, set your video frame count down into the low teens before you click Get the Code. Sixty frames won't "mostly fit." The linker is binary about this. Your sketch fits, or it doesn't. Sync to video changes playback speed so the samples last as long as the clip. It doesn't compress the arrays. If you uncheck it and run at 15 fps, you change the delay, not the flash use.
Dithering and threshold change which bits inside the 1024 bytes are 1 or 0. They don't change the length of the array. A speckled frame and a stark frame are the same size. Students sometimes re-export "to make it smaller" by sliding the threshold, and the compile bar doesn't budge. You'd see the same bytes.
ESP32 and a 4MB ESP8266, in terms you can use
Move boards when the bitmap total crosses what's left of the Uno's 32 KB, not after you've already deleted half your art. I'd rather you switch early. Here's a comfortable rule. If frame count × 1024 is over about 16 KB, stop and pick an ESP, or cut the loop on purpose.
- ESP32: SDA on GPIO21, SCL on GPIO22, OLED VCC on 3.3V, address usually 0x3C. Flash is measured in megabytes on the common modules. A 200-frame loop is a small file there. You still draw through a 1024-byte SRAM buffer, and you don't need to keep all 200 frames in RAM.
- ESP8266 NodeMCU: SDA on D2 (GPIO4), SCL on D1 (GPIO5), VCC on 3.3V. In Tools, set Flash Size to the 4MB option that leaves a large sketch area. A 1MB setting with a big filesystem can reject a 150 KB table even though you've got a NodeMCU. A 512 KB profile won't hold any of the loops in the table.
- Uno / Nano: SDA A4, SCL A5, 5V acceptable on modules with a regulator, address 0x3C. Budget about 12-18 full frames after libraries, and fewer if you also pull in sensors or a second display buffer.
Mega 2560 is the AVR exception for some of the mid-size loops: 256 KB of flash can hold a 148 KB Kalayani table if you're careful with libraries, and the I2C pins are 20 and 21, not A4 and A5. A 200 KB Thangamaana table plus the core is tight on a Mega, and I wouldn't try it. I still point that one at an ESP32 or a 4MB ESP8266. SRAM on a Mega is 8 KB, so the single 1024-byte OLED buffer is comfortable. The wall you'll hit first on a Mega is flash, and only for the longest clips.
How you read the IDE after a song sketch fails
Compile, then look at two sentences. That's all you'll need.
- "Sketch uses N bytes (P%) of program storage space." Program storage is flash. On Uno the maximum is about 32256 bytes. If N is missing because the link failed, the error text ("text section exceeds available space," "region `iram` overflowed," or a plain "sketch too big") is the flash wall. A 150 KB loop on an Uno fails here every time.
- "Global variables use N bytes (P%) of dynamic memory." Dynamic memory is SRAM, 2048 bytes on Uno. This line can look fine on a PROGMEM sketch that's still too big for flash, and it can look terrible on a sketch that fits in flash but copied a bitmap into RAM. Both lines matter, because they measure different pools.
A sketch that uploads and then resets usually points at the SRAM line, not the flash line.
The bootloader can flash a binary that then runs out of stack the first time
display.begin() builds the buffer. The classic cause on an Uno: your frame array
was missing PROGMEM, so 1024 bytes landed in SRAM beside the library's
own 1024-byte buffer. Two buffers and the stack collide. You'll see the panel flash once,
and then your board boots again. If you add PROGMEM and, on AVR, read a
pointer table with pgm_read_word, you'll stop that loop. An ESP32 isn't as picky
about the pointer read, because flash is mapped in the address space, which is why the
same source can look "randomly broken" only on the Uno.
A board mismatch hides inside these messages. If Tools says Arduino Uno while a NodeMCU is plugged in, you're compiling against 32 KB, and you'll see a flash error for a file that would have linked for the ESP8266. If Tools says ESP32 while an Uno is plugged in, the upload fails or the board sits there with a stale sketch. Match the menu to the chip, set the ESP8266 flash size, then compile again. You can trust the new percentages.
A loop that still fits, and how you time it
For an Uno I export a handful of full frames, or a small sprite, and I keep the player boring. Eight frames at 80 ms is a 0.64 second cycle and about 8 KB of bitmaps. That leaves room for the library, which is what you want. Here's the shape, with the AVR pointer read included so your picture isn't static noise:
const uint8_t* const frames[] PROGMEM = { frame0, frame1, frame2, frame3 };
const uint8_t FRAME_COUNT = 4;
void loop() {
static uint8_t i = 0;
static unsigned long lastMs = 0;
if (millis() - lastMs >= 80) {
lastMs = millis();
display.clearDisplay();
const uint8_t* f = (const uint8_t*)pgm_read_word(&frames[i]);
display.drawBitmap(0, 0, f, 128, 64, SSD1306_WHITE);
display.display();
i = (i + 1) % FRAME_COUNT;
}
}
Change 80 if you want a slower blink. Don't raise FRAME_COUNT unless you
add a real array. On ESP32 you can drop the pgm_read_word line and
index the table directly if your export does that. On an Uno, if you leave the
PROGMEM table and then use frames[i] as a normal pointer,
you get the bug that makes every frame look like snow while flash usage still looks correct.
uint8_t is enough for the index up to 200, so the type isn't why long
clips fail. The bytes are why. If you need the long clip, change the board. If you
need the Uno, change your art: fewer frames, a 32×32 sprite (128 bytes each, so a
hundred icons can fit), or GFX calls for anything that's a rectangle, a letter or
an eye. A drawn eye is tens of bytes of instructions. A bitmap of that eye is a
full kilobyte every time the pupil moves, and that's what hurts you.
Dual panels spend your SRAM twice
If you add a second SSD1306 on the same bus, you need its own object and its own 1024-byte buffer. Two buffers are the entire Uno SRAM before your frames. You can still share one PROGMEM clip across both objects, so flash costs once and SRAM costs twice, but you can't put two 128×64 buffers and a RAM bitmap on an Uno. If your dual-screen export resets, move to ESP32 (SDA GPIO21, SCL GPIO22, both panels on 3.3V, addresses 0x3C and 0x3D) or drop to 128×32 panels. The flash math for your frames doesn't care that two panels are attached. A 200-frame dual export of two different clips is about 400 KB of bitmaps. That's an ESP32 file. It isn't an Uno file, and it isn't a reason to split the bus.
The check I run before you plug the cable in
- Take frame count × 1024, and write the kilobytes in a sketch comment.
- Add about 12 KB for a normal Adafruit SSD1306 sketch, and more if you've put a second display object in the file (that extra is mostly SRAM, but the second driver still costs flash).
- If your flash guess is over ~28 KB, the board isn't an Uno. Pick an ESP32 or a 4MB ESP8266, or delete frames in the maker and export again.
- After you compile, confirm program storage and dynamic memory as two separate numbers. Fix PROGMEM if SRAM is the one in trouble, and change the board if flash is.
- Only then pick your port and upload. If you get a black panel after a clean compile, it's wiring or address (A4/A5 on Uno, 0x3C, or 0x3D if begin fails). It isn't the frame budget, which already had its chance to fail the link.
Related guides you might like
- SSD1306 animation playback
- Upload an OLED animation from GitHub to ESP8266
- ESP32 OLED guide (when Uno is too small)
- GIF to OLED, then trim frames
Preview frame count before you hit Uno limits
Build your animation in the browser, keep an eye on the frame count and export Adafruit code.
Open the free tool →Free tools: OLED Animation Maker for your SSD1306 and SH1106 animations, Assemble Studio for your name and logo animations, the Shadow Box Lamp Generator for your 3D-printed shadow lamps, Text to STL for your 3D-printed names and keychains, and 3MF to Web to show your 3D prints on any website. New: the Image to Byte Array converter, the OLED Robot Eyes generator and the Lithophane Maker. See all tools.