# Detour: Arduino Benchmark with Mandelbrot

A project log for VGA Shield Wing

A VGA Arduino Uno Shield or Adafruit Feather Wing 640x480 - 512 colours

With a display and a bunch of different Arduino/Feather boards, I figured it would be a fun little exercise to see how fast those boards would render a Mandelbrot set image with my video shield. Contestants are Arduino Uno, Mega, Due and a Feather M4 Express in NTSC320x200 and PAL300x240 resolutions. Calculations are done in float numbers for the standard number range of -2.5<x<+1 and -1<y<1. Results are rounded to the next full 0.1 second.

 Board NTSC 320x200 PAL 300x240 Uno 260.5 293.1 Mega 273.5 307.8 Due 35.8 42.9 FeatherM4 1.1 1.4

And here is a bad quality demo picture of the resulting image.

The code is not optimized for speed, I have read about implementation that use only 3 multiplications instead of 6. Work for the future.

```// Draw a Apfelmaennchen
void Mandelbrot (byte channel, float Xn, float Xp, float Yn, float Yp){
float x0, y0, xtemp;
float x = 0;
float y = 0;
u_int16 Px, Py;
u_int16 iteration = 0;
u_int16 max_iteration = 256;

for (Py = 0; Py < YPIXELS; Py++){
y0 = (Yp - Yn)/YPIXELS*Py + Yn;
for (Px = 0; Px < XPIXELS; Px++){
x0 = (Xp - Xn)/XPIXELS*Px + Xn;
x = 0;
y = 0;
iteration = 0;
while ((x*x + y*y <= 2*2) && (iteration < max_iteration) ) {
xtemp = x*x - y*y + x0;
y = 2*x*y + y0;
x = xtemp;
iteration++;
}
P42Display.SetYUVPixel (channel, Px, Py, (byte) (iteration&0xff) +0x20);
}
}

}
```