Pages: [1]   Go Down
Author Topic: Re: Code for cross-fading 3 LEDs  (Read 328 times)
0 Members and 1 Guest are viewing this topic.
Austin, TX USA
Offline Offline
God Member
*****
Karma: 5
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi eclipsemints--

I'd recommend changing this

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

to this

Code:
 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

Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 5
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: October 25, 2008, 10:57:32 pm by mikalhart » Logged

Pages: [1]   Go Up
Jump to: