OLED Animation Maker OLED Maker
🎵 Free Arduino project · SSD1306

Kalayani Song OLED Animation

Play the Kalayani song as a looping mono animation on your 0.96" SSD1306. You get 148 PROGMEM frames and a ready-to-flash Adafruit sketch, free on GitHub.

By Ashish Sep 16, 2026 ~10 min read Arduino · ESP8266 · ESP32
🎞️

148 song frames

You get the full Kalayani visuals as 1024-byte PROGMEM bitmaps for 128×64.

⚡

Plug & play sketch

It's Adafruit SSD1306 + GFX. Open code.ino and upload it.

🔌

Clear wiring

You'll find Uno / ESP8266 / ESP32 pin tables below.

🆓

Free on GitHub

Clone it or grab the ZIP. There's no paywall and no signup.

Pixel art of a girl with a star wand surrounded by floating music notes, for the post Kalayani Song OLED Animation

Want the Kalayani song to come alive on a tiny 0.96" SSD1306 OLED? This project plays a full 148-frame mono animation loop using Adafruit SSD1306. It works for desk toys, classroom demos, music-themed builds and your own GIF-to-OLED experiments.

OLED Animation Maker import tab for images, GIFs and video with threshold and dithering options

⬇ Free download, Kalayani OLED code

You get the full code.ino with all PROGMEM frames · ZIP or git clone

Open GitHub repo →

Parts list

  • Board: ESP8266 NodeMCU / Wemos D1 Mini, ESP32 or Arduino Mega (I'd pick one of these)
  • Display: 0.96" SSD1306 I2C OLED, 128×64. Yours usually answers at 0x3C
  • 4 Dupont wires (VCC, GND, SDA, SCL)
  • A USB cable and Arduino IDE

Connection / wiring

Match your board. Wrong SDA/SCL is the top reason you'll see a blank screen.

OLED pinArduino Uno / NanoESP8266 (NodeMCU)ESP32
VCC5V (or 3.3V if module requires)3.3V3.3V
GNDGNDGNDGND
SDAA4D2 (GPIO4)GPIO21
SCLA5D1 (GPIO5)GPIO22

On ESP8266, call Wire.begin(4, 5) before display.begin() if the default I2C pins fail. If your screen stays black, try address 0x3D and read OLED blank screen fixes.

Libraries

  1. Arduino IDE → Tools → Manage Libraries
  2. Install Adafruit SSD1306
  3. Install Adafruit GFX Library
  4. Select your board and the right COM port

How the player works

All frames are stored as const uint8_t PROGMEM frameN[1024]. In loop() the sketch moves the index forward on a timer and draws the current bitmap:

void loop() {
  static uint8_t frameIdx = 0;
  static unsigned long lastMs = 0;
  const uint8_t* frames[] = { frame0, frame1, /* ... */ frame147 };
  const uint8_t numFrames = 148;

  if (millis() - lastMs >= 318) {
    lastMs = millis();
    display.clearDisplay();
    display.drawBitmap(0, 0, frames[frameIdx], 128, 64, SSD1306_WHITE);
    display.display();
    frameIdx = (frameIdx + 1) % numFrames;
  }
}

Change 318 to speed up or slow down the song timing. Smaller means faster FPS (for example, 100 ≈ 10 fps).

Upload & run

  1. Open kalayanionoled and download the ZIP, or clone it
  2. Open code.ino in your Arduino IDE
  3. Install Adafruit GFX + SSD1306 if you haven't already
  4. Pick your ESP8266 / ESP32 / Mega and COM port
  5. Click Upload
  6. Watch Serial at 115200. If you see SSD1306 allocation failed, fix your power, wiring or address

Ready to flash?

Grab the complete Kalayani code.ino from GitHub now.

⬇ Download code

Make your own song animation

I exported Kalayani from oledanimationmaker.com, and you can do the same:

  1. Open the free tool in Chrome or Edge
  2. Go to Import and drop in a short GIF or video clip
  3. Tune the FPS and frame count to fit your board's flash
  4. Click Get the Code and choose Adafruit SSD1306 Arduino
  5. Paste it into your IDE, or push it to your own GitHub

Related guides: GIF to OLED, Image to byte array, SSD1306 animation basics.

Troubleshooting

  • Sketch too big, so use an ESP8266/ESP32 or cut some frames
  • Blank OLED, so use 3.3V on an ESP, check your SDA/SCL and try 0x3D
  • Slow / laggy, so keep your frame delay at 50-80 ms or more and use solid USB power
  • Compile OOM, so on ESP8266 set a higher flash size in Tools
  • Garbage at end of file, so delete any stray characters after the last } in code.ino

FAQ

Is the Kalayani OLED code free?

Yes, it's free. You'll find it at github.com/itzmeAshish/kalayanionoled.

Does it play audio?

No, it's a visual OLED animation only. If you need sound, you'll have to add a speaker separately.

Can I change the song?

Yes, you can. Import a different GIF/video into OLED Animation Maker and export a new sketch.

Build more OLED song & GIF animations

You get a pixel editor, GIF import, WebSerial live preview and Arduino & MicroPython export. It's free in your browser.

Open OLED Animation Maker →
Generated Arduino code window in OLED Animation Maker with Adafruit SSD1306 includes and PROGMEM frames

What code.ino holds for Kalayani

The GitHub repo itzmeAshish/kalayanionoled is a single Adafruit sketch, code.ino. It isn't a library, and it doesn't read a GIF at runtime. Everything your OLED will ever show is already compiled into the file: 148 bitmaps named frame0 through frame147, each const uint8_t PROGMEM and each exactly 1024 bytes. A pointer table lists those arrays in order. setup() starts Serial at 115200 and starts the SSD1306 at 0x3C, then loop() draws one bitmap every 318 ms.

This is the picture loop for Kalayani only. The sketch has no audio pin, no MP3 decoder and no lyric text. If you want the song itself, you'll need a separate player. This build is the 0.96" visual that goes with the title.

Arduino IDE wants the folder name to match the file. After you unzip, rename the folder to code and then open code.ino. If you leave the folder named kalayanionoled, the IDE often asks to move the sketch or makes a second copy. The file isn't main.ino in this repo, so don't rename the folder to main unless you rename the file too.

Kalayani timing table

The stock step is 318 ms, about 3.1 fps. One pass of all 148 frames is 148 × 318 ms ≈ 47 seconds. That slow step is why you'll still see this loop clearly on a 100 kHz I2C bus. Pushing 1024 bytes takes roughly 90 ms, so 318 ms gives the transfer room to finish before the next index.

Delay in loop()Approx. fpsFull 148-frame passWhen to use it
500 ms2~74 sA desk piece you glance at, not a music cue
318 ms (stock)~3.1~47 sThe timing shipped in code.ino
200 ms5~30 sA bit snappier, still comfortable on default I2C
100 ms10~15 sBusy motion; raise the I2C clock if frames skip

Edit the number in the millis() test only. Leave numFrames at 148 unless you delete bitmap arrays too. If you set the count higher than the table, it reads off the end of the pointer list and your panel fills with garbage. If you set it lower, you'll play a prefix of the loop and then jump back to frame0. That's a fair way to preview your wiring before you trust the whole 47 second cycle.

Wiring when the comment still mentions Uno

The sketch comment lists Uno pins because that's the usual teaching default: SDA on A4, SCL on A5, VCC on 5V. Many 0.96" modules accept 5V thanks to an onboard regulator, and the address is 0x3C. Use those pins only if you've shortened the animation. For this file as published, you'll need a board that can store it.

  • ESP8266 NodeMCU: VCC to 3.3V, GND to GND, SDA to D2 (GPIO4), SCL to D1 (GPIO5). If your panel stays dark, add Wire.begin(4, 5) before display.begin().
  • ESP32: VCC to 3.3V, SDA to GPIO21, SCL to GPIO22. Don't use the Uno A4/A5 labels on an ESP32 DevKit, because those pins aren't the I2C defaults.
  • Arduino Mega 2560: the hardware I2C pins are still SDA 20 and SCL 21 (not A4/A5). The Mega has 256 KB of flash, so the 148 KB of bitmaps can fit. The comment's "A4/A5" line is the Uno map, and you shouldn't use it on a Mega.

Four dupont wires are enough, and you should keep them short. A 30 cm jumper pair on SDA and SCL is a frequent cause of a panel that works on your desk and dies when you move the project.

Why a classic Uno can't play these 148 frames

Flash on the ATmega328P is about 32 KB, and the bootloader already keeps a slice of it. Your bitmaps alone are 148 × 1024 = 151,552 bytes, roughly 148 KB, before Adafruit GFX, SSD1306 and Wire. That's several times the whole Uno. You'll get a "sketch too big" error from the IDE, and no optimizer will squeeze a 148 KB table into 32 KB.

The classic Nano (not Nano ESP32 or Nano Every) has the same 32 KB ceiling. A Mega 2560 can hold this particular sketch. An ESP32, or an ESP8266 module with 4MB of flash, is the comfortable choice, and it's what I'd use. It matches the other long loops on this site. If you only own an Uno, reopen the clip in OLED Animation Maker, cut the frame count into the low teens, and export again. Don't delete random frameN arrays in the middle of code.ino unless you rebuild the pointer table too. A hole in that list is worse than a short loop.

Changing the 318 ms step

Find the comparison millis() - lastMs >= 318 in the sketch. Replace 318 with a value from the table, upload again, and watch one full pass before you decide. I'd always check a full pass. The index wraps with frameIdx = (frameIdx + 1) % numFrames, so the loop never ends. You don't need a second timer for "end of song." There's no audio to stay in sync with.

If you type a delay below about 80 ms, display() becomes the real clock. Your OLED will still advance, but the gap you typed is a minimum, not a promise. For Kalayani's stock 318 ms you won't hit that floor. Go slower (a larger delay) when you're filming, so each picture sits long enough for your phone to catch it.

A recording that shows the Kalayani loop honestly

Film the module, not the GitHub page. Fill your phone frame with the glass. Kill the ceiling light behind you so the cover glass doesn't mirror the room. OLED pixels are either lit or not, and a wide shot of your whole bench makes 128 columns look like dust.

Record at least 50 seconds so one 47 second pass completes on camera. You should see the picture change, return to the opening frame and keep going. A take that stops at 10 seconds only proves the first handful of bitmaps, and you won't learn much from it. If the motion looks slower than the song you remember, that's the 318 ms step, not a dropped upload. This project doesn't play the track, so a silent video of the panel is what you should get.

When upload succeeds and the panel does not

  • Black screen: ESP boards must feed VCC from 3.3V. The 5V pin on a NodeMCU isn't the logic supply for your display. Reseat SDA and SCL. On ESP8266, D2 and D1 are easy to swap because the silk is tiny.
  • Wrong address: SSD1306 allocation failed on Serial at 115200 usually means begin() didn't see 0x3C. Change the address to 0x3D and upload once. If both fail, the chip isn't on the bus, so check your GND before you change libraries.
  • IDE board mismatch: a sketch compiled as "Arduino Uno" and sent to a NodeMCU won't run this file, and a sketch compiled as ESP32 won't run on an 8266. Pick the board that matches your USB chip, then pick the port that appears when you plug the cable in. If the menu has no entry for your module, install the ESP8266 or ESP32 board package.
  • Not enough flash: on ESP8266 open Tools → Flash Size and choose the 4MB option that matches your module. A 512 KB or 1MB setting rejects a 148 KB bitmap table even when the chip is larger. The Uno error is the same problem, but you've got no menu that can fix it.

Kalayani bench questions

Does this sketch play the Kalayani audio?

No. code.ino is 148 monochrome frames on a 128×64 SSD1306, and there's no speaker code. The title is the song name. Your OLED plays the visual only.

I cloned kalayanionoled and the IDE complains about the sketch name. What folder do I use?

The file is code.ino, so you need to name the folder code. It isn't the main.ino layout some of the other song repos use. Rename the folder, then open the file from inside it.

Can I keep the 148 frames and still use an Uno if I lower the fps?

No. The delay only changes timing, and the bytes still sit in flash. 148 KB doesn't fit in 32 KB at any frame rate. Use an ESP32, a 4MB ESP8266 or a Mega, or export a much shorter frame list.

How do I know the 318 ms loop is actually running?

Time one pass with a watch. From the first picture back to the same picture should take about 47 seconds. If a pass takes closer to 15 seconds, you've edited the delay to 100 ms. A frozen first frame means the loop isn't advancing, which points back at upload, power, or begin() failing before loop() draws. It's rarely the animation.

Related posts

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.