Led not turning on

/* Full Color Led Control by Connecting Common Anode Pin, and use PWM 
*/

//define the pin color
const int redPin=9; // definition of Red LED Pin
const int greenPin=10; // definition of Green Led Pin
const int bluePin=11; // definition of Blue Led Pin

//Timer
int Timer=50; //timer amount

//Function to change color using RGB values
void setColor(int red, int green, int blue){
  analogWrite(redPin, red); 
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);
}

void setup() {
  // put your setup code here, to run once:
pinMode(redPin,OUTPUT); // set the red Led Pin as output mode
pinMode(greenPin,OUTPUT); // set the green Led Pin as output mode
pinMode(bluePin,OUTPUT); // set the blue Led Pin as output mode
}

void loop() {
  setColor(0, 255, 255); // Red
  delay (Timer);

  setColor(255, 0, 255); // Green
  delay (Timer);

  setColor(255, 255, 0); // Blue
  delay (Timer);

    setColor(0, 0, 255); // Blue
  delay (Timer);

    setColor(255, 0, 0); // Blue
  delay (Timer);

    setColor(0, 255, 0); // Blue
  delay (Timer);

    setColor(0, 0, 0); // Blue
  delay (Timer);
}

Do you think you can detect the light in just 50 milliseconds? Try 1000 milliseconds.

2 Likes

Common Anode.

What is the (presumably) common pin on the LED connected to?

1 Like

The project looks OK except as @Paul_KD7HB pointed out we do not believe your eyes are fast enough. Adjust the time as suggested and it should work.

Your 5V pin goes nowhere.

1 Like

Not if @van_der_decken and @sonofcy are correct!

2 Likes

Hi,
Code works with 100ms delay, but as previously said, is the LED common anode or cathode.
From what I have here it is common ANODE.
So needs a simple rewire.

Tom.. :smiley: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.