Re: Code for cross-fading 3 LEDs

hi eclipsemints--

I'd recommend changing this

int redPin   = 9;   // Red LED,   connected to digital pin 9
int greenPin = 10;  // Green LED, connected to digital pin 10
int bluePin  = 11;  // Blue LED,  connected to digital pin 11

to this

int redPin1  = 9;   // Red LED,   connected to digital pin 9
int greenPin1 = 10;  // Green LED, connected to digital pin 10
int bluePin1  = 11;  // Blue LED,  connected to digital pin 11
int redPin2   = 3;   // Red LED,   connected to digital pin 3
int greenPin2 = 5;  // Green LED, connected to digital pin 5
int bluePin2  = 6;  // Blue LED,  connected to digital pin 6

and this

  analogWrite(redPin,   redVal);   // Write current values to LED pins
  analogWrite(greenPin, greenVal);
  analogWrite(bluePin,  blueVal);

to this

  analogWrite(redPin1, redVal);   // Write current values to LED pins
  analogWrite(greenPin1, greenVal);
  analogWrite(bluePin1, blueVal);  
  analogWrite(redPin2, redVal);
  analogWrite(greenPin2, greenVal);
  analogWrite(bluePin2, blueVal);

Note that analogWrite only works with pins 3, 5, 6, 9, 10, and 11. See analogWrite() - Arduino Reference.

Mikal

Hmm... what kind of Arduino do you have? The older ones only supported PWM on pins 9, 10, 11. Is the 3, 5, 6 LED just blinking on and off? If so, I'm guessing you have an NG.

Mikal