© ArduTV 2025

ArduTV - TV Interface shield for Arduino.

Privacy Policy

0f8568db-b6ab-468a-9cb7-d310fd166dab

Simple Mandelbrot-Set Graph drawing

In this super-simple example a Mandelbrot-Set is drawn on the television using an Arduino UNO board. Changing the cR, cX, zR and zX parameters you can "explore" the set! 

NOTE: the code is an adaptation to ArduTV command of the code found on this thread here: https://forum.arduino.cc/t/help-me-to-solve-how-to-draw-mandelbrot/609925/8, so thanks to "arduino1445ll" and "johnwasser".

The following code continuously generates a Mandelbrot set.

#include <ArduTV.h>

ArduTV HDMI1(10);

void setup() {

  HDMI1.begin();

  HDMI1.BGColor(20,20,20);

  HDMI1.PenColorDir(234);

  HDMI1.Clear();

}

void loop() {

        for(int y = 240; y > -240; y--){

          for(int x = -320; x < 320; x++){

           float cR = x/120.0;

           float cX = y/120.0;

           float zR = 0.5;

           float zX = 1;

           int r = 0;

            do{

              r++;

              float old_zR = zR;

              zR = cR+((zR*zR)-(zX*zX));

              zX = (2*old_zR*zX)+cX;

            } while(!(r > 50 || zR > 2));

            if (zR < 2){

                HDMI1.PointDir(x+320, y+240,0);

            }

            else{

                HDMI1.PointDir(x+320, y+240,r*5000);

            }

        }

      }

}

f71d83f6-1549-49f8-aa26-9480f89d983e
a45ba104-5e62-4180-aa88-31d1e85d20de

© ArduTV 2025

Privacy Policy