LEDs Not Bright Enough

I’ve had my Arduino for five days and I can’t put it down. I have a lot to learn about electronics and it’s such a great learning tool.

My current experiment has three LEDs connected to digital pins 2, 3, and 4 connected in parallel with 1K resistors. They share the ground pin. I wrote a sketch that cycles through them. The LEDs light up fine if I only have one connected but when they’re all connected only the pin 2 LED is bright. My power is coming from the USB. I originally used 10K resistors but I thought there was too much resistance so I reduced it. Why are the LEDs so dim?

Here’s my sketch:

// Three Lights - Cycle through three LEDs in a cool pattern. 

int ledPin = 2;     // LED connected to digital pin 2
int interval = 1000; // time between blinks (milliseconds) 

void ledBlink(int ledPin, int delayInterval){
    digitalWrite(ledPin, HIGH);   // set the LED on
    delay(delayInterval);         // delay
    digitalWrite(ledPin, LOW);    // set the LED off
    delay(delayInterval);         // delay  
}

void setup()   {                
  pinMode(ledPin, OUTPUT);     
}

void loop(){
  for(int i = 2; i < 5; i++){  // cycle through LEDs 2-4
    ledBlink(i, interval);
  }
  ledBlink(3, interval);  // cycle back to the first LED
}

First what is LED? LED is Light emitting diode. The LED means just small light which we are seeing now day in adapter or in any electronic product. which are used for power on or off.


Garmin GPS Reviews

SPAM

@OP - you need to set the pinMode to OUTPUT for all three pins that have LEDs connected. By default, pins are inputs, so all you're doing with the "digitalWrite"s is enabling and disabling the internal pull-ups. These will act as current limiters, but they're very high values, so the LEDs will appear dim.

Are the lights connected to pin 3 and pin 4 bright or just dim?
I guess the main problem doesn’t lie in PinMode setup,but lies in the way you define pins. :-/

1 Like

I guess the main problem doesn't lie in PinMode setup,

No, the problem lies in the fact that the pinMode for pins 3 and 4 isn't set to OUTPUT. No need to guess.

ledBlink(3, interval);  // cycle back to the first LED

Comment doesn't appear to match code.

Also:-

connected in parallel with 1K resistors.

I hope you mean series, that way you limit the current.

A 1K series resistor is too big for most LEDs, you need a value of around 200 to 470R.

doesn't lie in PinMode setup,but lies in the way you define pins

The pinMode IS the way you define the pins.

By default, pins are inputs, so all you're doing with the "digitalWrite"s is enabling and disabling the internal pull-ups. These will act as current limiters, but they're very high values, so the LEDs will appear dim.

Thanks for all the replies. Groove you hit the nail on the head (or the pin as it were). I tried to be slick and set the pin mode for all at once using the variable but I overlooked the fact that the variable only represented one pin when pinMode() executed.

ledBlink(3, interval); // cycle back to the first LED

Comment doesn't appear to match code.

I have created an oscillating effect with the lights - cycling back and forth. The for loop cycles through the three LEDs in one direction but in order to cycle back to the beginning I have to light the middle one once.

Thanks for the help it works great now! I slowed the interval down for the video. I think it looks cool at around 75ms. http://www.youtube.com/watch?v=8_KX1CjjFNY