Pages: [1]   Go Down
Author Topic: Problem with RGB code.  (Read 497 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Im using the code below to light up an RGB LED, the green and the red are working but the blue doesn't.

Does anyone know why ?

Thanks

/* RGB Fading Example

*/


int RLedPin = 11;       // Red LED connected to PWM digital 11
int GLedPin = 10;       // Green LED connected to PWM digital 10
int BLedPin =  9;       // Blue LED connected to PWM digital 9
int fadeDelay = 5;
int fadeStep  = 1;

void setup()    {    // do nothing here
}

void loop()    {
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=fadeStep){
    analogWrite(RLedPin, fadeValue) ;
    delay(fadeDelay) ;
  }
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=fadeStep){
    analogWrite(RLedPin, fadeValue) ;
    delay(fadeDelay) ;
  }
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=fadeStep){
    analogWrite(GLedPin, fadeValue) ;
    delay(fadeDelay) ;
  }
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=fadeStep){
    analogWrite(GLedPin, fadeValue) ;
    delay(fadeDelay) ;
  }
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=fadeStep){
    analogWrite(BLedPin, fadeValue) ;
    delay(fadeDelay) ;
  }
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=fadeStep){
    analogWrite(BLedPin, fadeValue) ;
    delay(fadeDelay) ;
  }
}
« Last Edit: April 11, 2012, 04:32:17 am by 03coupr » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The first thing to check is whether it is a hardware problem or a software problem. Switch the legs of the RGB  LED around. Is the problem confined to a pin, or to a color?
Logged

Pages: [1]   Go Up
Jump to: