LEDS dim on DIgital pins

Hi! everyone so im trying to make a traffic lighting system on the arduino (UNO). So i went ahead and yacked out 12 LEDS and connected each LED to a different Digital pin. I gave the LEDS a common ground (by connecting the cathodes to a single negative rail on the breadboard). the positive input for each was separate, as it came from different pins. I setup my code and its works. Its just that the LEDs are extremely dim and not at full brightness (note i had not connected any resistor) , i have attached my code file below, Any ide what to do? with resistors (1k ohm) the Leds would be even dimmer.

leds2.ino (381 Bytes)

note i had not connected any resistor

Fix that first.

Please remember to use code tags when posting code.

That code does not work. digitalWrite(ledPin[0]) doesn't write to any of your LEDs.

Steve

I'm wondering how it works at all, since the only led you're ever controlling according to that uploaded code is ledPin[0], ie pin 2.

You need a delay() at the bottom of the for(), after where you make the led low.

And defo need a resistor on each one; you may have done some damage already.

TheMemberFormerlyKnownAsAWOL:
Fix that first.

Please remember to use code tags when posting code.

Roger that! Be glad you messed up your code, otherwise you would have blown the leds for sure :wink:

Can't see the code as it is not posted according to the instructions, but the usual cause for very dim LEDs is omitting to set the corresponding pins to OUTPUT.

At least if you fail to set the corresponding pins to OUTPUT, you will not damage anything by omitting the essential series resistors. :grinning:

int ledPin[12] = {2, 3, 4, 5, 6, 7, 8, 9, 10 , 11, 12, 13};





 void setup() {
  // put your setup code here, to run once:
   pinMode(ledPin, OUTPUT);  // OOOPS

   
   
}


void loop() {
  // put your main code here, to run repeatedly:
  for(int x = 0; x<=12; x++){    // OOOPS
    digitalWrite(ledPin[0], HIGH);
    delay(3000);
    digitalWrite(ledPin[0], LOW);
  }
 }

OP's code, my OOOPS

Yep, failing to set the pins to OUTPUT means writing them HIGH is effectively setting them to INPUT_PULLUP and an effective 47k resistor to 5 V, so given the LEDs about 75 microamps each. :grinning:

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