So, I got bored and decided that the best way to show you was to build my own led cube and program it for you, but I didn’t want it to be a wussy cube, so I made it RGB to make it pop. Anyways *checks to see if anybody believed that story*

```
void sineWave3d(){
byte y[8][8];
float rads = 0;
float t = 0;
while(1){
for(int x = 0; x < 8; x++){
for(int z = 0; z < 8; z++){
rads = ((float)sqrt((x-4)*(x-4) + (z-4)*(z-4)) / 4.) * 3 + t; //change that 3 to make it shrink/expand
t += 0.005; //time, change this to make it speed up/slow down
while(t > TWO_PI) //limit to 2PI, wrap around if overflow
t -= TWO_PI;
while(rads > TWO_PI) //limit to 2PI, wrap around if overflow
rads -= TWO_PI;
setLED(x, y[x][z] , z, 0, 0, 0); //clear old LED
y[x][z] = 4 + sin(rads) * 3.999; //this is where the magic happens
setLED(x, y[x][z], z, r, g, b);
}
}
delay(50);
}
}
```

This works because the LED chosen to light up is based on the distance from the center, that distance is put into the sine function. Then a time variable is added, which causes an animation. If you want to make more sense of it, convert this code for yourself and simply comment “t += 0.005” which will make it all stand still.