user30029: How do you make a fading led with 8 different colors I already made a blinking led every 1 second. Can you give me an idea how am I going to fade it every time it switch?
const int red = 5; 
const int green = 6; 
const int blue = 9; 

void setup() { 
    // put your setup code here, to run once: 
    pinMode(red, OUTPUT); 
    pinMode(green, OUTPUT); 
    pinMode(blue, OUTPUT);  
}  

void loop() { 
    lightMe(red); 
    lightMe2(red, green);  // yellow 
    lightMe(green); 
    lightMe2(green, blue);  // cyan 
    lightMe(blue); 
    lightMe2(blue, red);  // magenta 
    lightMe3(red, green, blue); // white 
} 

void lightMe(int pin){ 
    digitalWrite(pin, HIGH); 
    delay(1000); 
    digitalWrite(pin, LOW); 
    delay(500); 
} 

void lightMe2(int pin1, int pin2) { 
    digitalWrite(pin1, HIGH); 
    digitalWrite(pin2, HIGH); 
    delay(1000); 
    digitalWrite(pin1, LOW); 
    digitalWrite(pin2, LOW); 
    delay(500);  
} 

void lightMe3(int pin1, int pin2, int pin3) { 
    digitalWrite(pin1, HIGH); 
    digitalWrite(pin2, HIGH); 
    digitalWrite(pin3, HIGH); 
    delay(1000); 
    digitalWrite(pin1, LOW); 
    digitalWrite(pin2, LOW); 
    digitalWrite(pin3, LOW); 
    delay(500);  
} 


user10394: You could look at this example, which fades an LED using PWM.
https://www.arduino.cc/en/Tutorial/Fading
Basically you use analogWrite to control the output of the pins with finer resolution, 0-255 rather than 0-1.  Only certain pins support PWM, they should be marked on your board.  You just need to extend the example to support your LED.  (Put the resistor on the common pin)

30029: <p>How do you make a fading led with 8 different colors I already made a blinking led every 1 second. Can you give me an idea how am I going to fade it every time it switch?</p>

<pre><code>const int red = 5; 
const int green = 6; 
const int blue = 9; 

void setup() { 
    // put your setup code here, to run once: 
    pinMode(red, OUTPUT); 
    pinMode(green, OUTPUT); 
    pinMode(blue, OUTPUT);  
}  

void loop() { 
    lightMe(red); 
    lightMe2(red, green);  // yellow 
    lightMe(green); 
    lightMe2(green, blue);  // cyan 
    lightMe(blue); 
    lightMe2(blue, red);  // magenta 
    lightMe3(red, green, blue); // white 
} 

void lightMe(int pin){ 
    digitalWrite(pin, HIGH); 
    delay(1000); 
    digitalWrite(pin, LOW); 
    delay(500); 
} 

void lightMe2(int pin1, int pin2) { 
    digitalWrite(pin1, HIGH); 
    digitalWrite(pin2, HIGH); 
    delay(1000); 
    digitalWrite(pin1, LOW); 
    digitalWrite(pin2, LOW); 
    delay(500);  
} 

void lightMe3(int pin1, int pin2, int pin3) { 
    digitalWrite(pin1, HIGH); 
    digitalWrite(pin2, HIGH); 
    digitalWrite(pin3, HIGH); 
    delay(1000); 
    digitalWrite(pin1, LOW); 
    digitalWrite(pin2, LOW); 
    digitalWrite(pin3, LOW); 
    delay(500);  
} 
</code></pre>
 10394: <p>You could look at this example, which fades an LED using PWM.</p>

<p><a href="https://www.arduino.cc/en/Tutorial/Fading" rel="noreferrer">https://www.arduino.cc/en/Tutorial/Fading</a></p>

<p>Basically you use <code>analogWrite</code> to control the output of the pins with finer resolution, 0-255 rather than 0-1.  Only certain pins support PWM, they should be marked on your board.  You just need to extend the example to support your LED.  (Put the resistor on the common pin)</p>
