Hi I have an rgb set up to react to sound with red triggering at highest levels and green lowest. at present when no detecable sound I can set each LED to shine or not between 0 and 255. What I would like is, when I have no sound, for the lights to fade through the colours like your sketch I presume? I am a couple of weeks into Arduino with no programming background. Could I tag your sketch onto the existing sketch I am using, so instead of just static light when no noise, the rgb reacts to your sketch, but when there is sufficient noise the original sketch reacts whilst yours switches off?

Is it some kind of "if" function connected to the output of A0 (what the sound sensor is connected to?

here is the sketch i'm using (thanks to Alejandro Taracido Cano):

int sensorValue = analogRead(A0); // pin that the mic is attached to



int redPin = 9; // pins that the cathodes of LED are attached to

int greenPin = 10;

int bluePin = 11;



int MicValue = 0; // the Microphone value



void setup() {

//Serial.begin(9600); //for test the input value initialize serial

pinMode(redPin, OUTPUT);

pinMode(greenPin, OUTPUT);

pinMode(bluePin, OUTPUT);



analogWrite(redPin, 50); //turn off all LEDs

analogWrite(greenPin, 50);

analogWrite(bluePin, 50);

}



void loop() {



MicValue = analogRead(A0); //read the value of the microphone



//Serial.println(MicValue); //for test the input value



if (MicValue > 400) { //adjust this value to the desired sensitivity

analogWrite(bluePin,0); //lights up blue

delay(15); //small delay for quick response at low noise levels

}



if (MicValue > 500) { //adjust this value to the desired sensitivity

analogWrite(bluePin,255); //lights up green and turn off blue

analogWrite(greenPin, 0);

delay(60); //mid delay for response at mid noise levels

}



if (MicValue > 650) { //adjust this value to the desired sensitivity

analogWrite(greenPin,255); //lights up red and turn off green

analogWrite(redPin, 0);

delay(140); //high delay for response at high noise levels

}



analogWrite(greenPin, 255); //Turn off all LEDs

analogWrite(redPin, 255);

analogWrite(bluePin,50);



}

I am looking at your code now so may find a solution in the meantime, but any help gratefully received!