An Arduino Nano that draws endless random fractals
I started with a digital pet on an Arduino Nano and OLED, then changed it into a fractal generator. It picks a new type, zoom, rotation and filter every few seconds and rejects mostly blank images.
Results
2 KBof RAM to work with
4fractal types, picked at random
5 sbetween new images, with no buttons
The problem
The Nano has very little memory and the 2.42-inch, 128×64 OLED shows one color. Over I2C the display stayed blank or flashed random pixels. And at this size many random fractals come out as an all-white or all-black screen.
What I did
- Found a working setup in the library examples: 4-wire software SPI with the SSD1306 driver, after I2C and the SSD1309 constructors showed nothing or failed to compile.
- A digital pet first: hunger and happiness stats, full-screen faces, blinking and heart animations, driven by three buttons.
- A fractal generator with Mandelbrot, Julia, Burning Ship and Tricorn sets, random zoom, offset and rotation, and invert, XOR and threshold filters.
- A fill check that rejects images with 1% or less, or 99% or more, of pixels lit, plus a retry guard after it got stuck re-rendering one rejected image.
- Serial debug output listing each image's type, filter, seed, fill ratio, zoom, offset and rotation.
What I took from it
The diagonal-wipe transition would not fit in the Nano program. I tried reducing debug output, then dropped the transition and kept the fractal generator working within the available memory.