Hi guys, I came across an instructables page for making a mood light with LEDs and a light diffuser. Ive implemented the provided code and it actually works a treat!

However, the code being does not fully make sense to me

```
// Smooth RGB mood lamp
// Changes an RGB LED's color smoothly
// ---------------------------------------------------
// The brightness of the leds follows these equations:
// Red = sin(x)
// Green = sin(x + PI/3)
// Blue = sin(x + 2PI/3)
// for x from 0 to PI
// ---------------------------------------------------
float RGB[3];
int redLed = 11; // red LED in Digital Pin 11 (PWM)
int greenLed = 5; // green LED in Digital Pin 5 (PWM)
int yellowLed = 3 ; // yellow LED in Digital Pin 3 (PWM)
void setup(){
pinMode(redLed,OUTPUT); // tell arduino it's an output
pinMode(greenLed,OUTPUT);// tell arduino it's an output
pinMode(yellowLed,OUTPUT); // tell arduino it's an output
// set all the outputs to low
digitalWrite(redLed,LOW);
digitalWrite(greenLed,LOW);
digitalWrite(yellowLed,LOW);
}
void loop(){
for (float x=0;x<PI;x=x+0.00001){
RGB[0]=255*abs(sin(x*(180/PI))); // calculate the brightness for the red led
RGB[1]=255*abs(sin((x+PI/3)*(180/PI))); // calculate the brightness for the green led
RGB[2]=255*abs(sin((x+(2*PI)/3)*(180/PI)));// calculate the brightness for the blue led
analogWrite(redLed, RGB[0]);
analogWrite(greenLed, RGB[1]);
analogWrite(yellowLed, RGB[2]);
for(int i=0;i<3;i++){
if(RGB[i]<1){
delay(100);
}
if(RGB[i]<5){
delay(50);
}
if(RGB[i]<10){
delay(10);
}
if(RGB[i]<100){
delay(5);
}
}
delay(1);
}
}
```

I dont understand the point of using the sin PI business…i mean…is that really necessary ?

Could someone please enlighten me?

Thanks in advance