Go Down

Topic: Re: Code for cross-fading 3 LEDs (Read 334 times) previous topic - next topic

mikalhart

hi eclipsemints--

I'd recommend changing this

Code: [Select]
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

Code: [Select]
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
Code: [Select]
 analogWrite(redPin,   redVal);   // Write current values to LED pins
 analogWrite(greenPin, greenVal);
 analogWrite(bluePin,  blueVal);


to this

Code: [Select]
 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 http://arduino.cc/en/Reference/AnalogWrite.

Mikal


mikalhart

#1
Oct 26, 2008, 04:56 am Last Edit: Oct 26, 2008, 04:57 am by mikalhart Reason: 1
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

Go Up