Anachrocomputer beat me to it:
void fade(int outPin)
{
for(int value = 4; value <= 250; value++)
for(int rep = 0; rep <= 10; rep++)
{
digitalWrite(outPin, HIGH); // sets the value (range from 0 to 255)
delayMicroseconds(value); // waits for 30 milli seconds to see the dimming effect
digitalWrite(outPin, LOW);
delayMicroseconds((255 - value));
}
}
if(duration < 2000)
fade(ledPin2)
if(duration < 1000)
fade(ledPin3);
if(duration < 500);
fade(ledPin4);
Is it just me or is Tab broken?