RGB lighting up same color

Dear coding fellows,

I bought some RGB led's for a school project. When I connect them to an arduino leonardo or mega. The RGB decides to only light up in blue for some reason. This is the code that i'm using it's just a basic code that I found only so I don't think there can be much wrong with that.

int redPin= 7;
int greenPin = 6;
int bluePin = 5;
void setup() {
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
}
void loop() {
  setColor(255, 0, 0); // Red Color
  delay(1000);
  setColor(0, 255, 0); // Green Color
  delay(1000);
  setColor(0, 0, 255); // Blue Color
  delay(1000);
  setColor(255, 255, 255); // White Color
  delay(1000);
  setColor(170, 0, 255); // Purple Color
  delay(1000);
}
void setColor(int redValue, int greenValue, int blueValue) {
  analogWrite(redPin, redValue);
  analogWrite(greenPin, greenValue);
  analogWrite(bluePin, blueValue);
}

Hi,
Have you some code that just sends PWM to each pin in turn, to make sure your circuit is working?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

Tom,

I found the problem thanks to you I wasn't using the PWM pins so thanks for pointing that out! The RGB's are working all fine at the moment