NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » Some LEDs are brighter than others on my LED array

July 18, 2011
by Sinabyte
Sinabyte's Avatar

First off, I've really been enjoying getting to know my NerdKit. It's really an outstanding product. I've learned quite a bit already thanks to this little guy.

I'm having a little snag building my LED array. I wired up a simple 12x5 LED array on a breadboard (I skipped the 24x5 size for later). For some reason the LEDs hooked up to PC0-PC5 columns are about half as bright as the ones wired up to PD2-PD7 columns at the same time. For my test program I am just turning all the columns high and the rows low, so that all my LEDs are on. My next step was going to be writing the interrupt code.

If I move the PD7 column wire over to the PD0 column, the LED is brighter. Furthermore, if i bypass the PB1-PB5 pins for the rows and hookup the rows directly to ground, they are bright on all the columns. So, the wiring all seems good.

As soon as I start adding and turning on PD columns, my PC columns start getting dimmer. It's like the PD pins have a stronger path to ground or something. My PC0-PC5 will be nice and bright, but each PD column I add makes them dimmer.

Any help or ideas would be appreciated. Maybe I damaged my AVR somehow or I got the wrong LEDs from digikey? I'm stumped! Thanks.

#define F_CPU 14745600

#include <avr/io.h>
#include <inttypes.h>

#include "../libnerdkits/delay.h"
#include "../libnerdkits/lcd.h"

int main() {

  // rows
  DDRB |= 1<< PB5;
  DDRB |= 1<< PB4;
  DDRB |= 1<< PB3;
  DDRB |= 1<< PB2;
  DDRB |= 1<< PB1;

  // columns
  DDRC |= 1<<PC5;
  DDRC |= 1<<PC4;
  DDRC |= 1<<PC3;
  DDRC |= 1<<PC2;
  DDRC |= 1<<PC1;
  DDRC |= 1<<PC0;

  DDRD |= 1<<PD2;
  DDRD |= 1<<PD3;
  DDRD |= 1<<PD4;
  DDRD |= 1<<PD5;
  DDRD |= 1<<PD6;
  DDRD |= 1<<PD7;

  while(1) {

    PORTB &= ~(1 << PB5);
    PORTB &= ~(1 << PB4);
    PORTB &= ~(1 << PB3);
    PORTB &= ~(1 << PB2);  
    PORTB &= ~(1 << PB1);

    PORTC |= (1 << PC5);
    PORTC |= (1 << PC4);
    PORTC |= (1 << PC3);
    PORTC |= (1 << PC2);
    PORTC |= (1 << PC1);
    PORTC |= (1 << PC0);

    // PC0-PC5 are bright

    delay_ms(3000);

    PORTD |= (1 << PD2);
    PORTD |= (1 << PD3);
    PORTD |= (1 << PD4);
    PORTD |= (1 << PD5);
    PORTD |= (1 << PD6);
    PORTD |= (1 << PD7);

    // PC0-PC5 are dim

    delay_ms(3000);

    PORTD &= ~(1 << PD2);
    PORTD &= ~(1 << PD3);
    PORTD &= ~(1 << PD4);
    PORTD &= ~(1 << PD5);
    PORTD &= ~(1 << PD6);
    PORTD &= ~(1 << PD7);

    // PC0-PC5 are bright again

  }

  return 0;
}
July 19, 2011
by bretm
bretm's Avatar

What value of current-limiting resistors are you using?

Are you on battery power or an A/C adapter?

Are you exceeding any of the current limitations described in the Electrical Characteristics chapter of the datasheet? (20mA per pin, sinking 100mA total for PB0 through PB5 plus PD5 through PD7, sourcing 150mA total for PD0 through PD4, sourcing 150mA total for PB0 through PB5 plus PD5 through PD7, etc.)

July 19, 2011
by Sinabyte
Sinabyte's Avatar

I'm not using any resistors, the anodes and cathodes are wired up directly to the AVR, which is how I thought the DIY Marquee is wired. Did I miss a step in my enthusiasm?

I tried USB power and a regulated 5 volt power supply from my arcade game parts collection and got the same result. I'll double-check the regulated power supply results again, but i'm pretty sure they were the same as USB powered. I figured it's probably not good to power so many LEDs through the USB, but I didn't think it would hurt anything temporarily while building this thing.

The LEDs I ordered from digikey are part # 160-1701-ND (LED 5MM HI-EFF RED TRANS).

I'm not sure about exceeding the current limitations. Since I'm not using any resistors that sounds like the right track, but I didn't see any mention of resistors in the DIY marquee. Most of the testing I did was with USB power.

July 19, 2011
by bretm
bretm's Avatar

I never built the LED array project so I don't know how it's wired. If a single pin is sinking an entire row of 12 LEDs, you're limited to 20mA/12 = 1.7mA which is probably a very dim LED. If you're seeing six bright LEDs with a single pin sinking them you're probably exceeding the 20mA limit. If they get dimmer as you add more columns I'd say you're definitely exceeding the limits.

Yes, you can damage the MCU doing this. Stick to battery power to make that less likely while you're experimenting.

July 19, 2011
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Sinabyte,

In the LED Array Kit we get away with a lot of things because of the way we wired up the LEDs, and the fact we are pulsing them on and off (they are running at a fairly low duty cycle). This means that we don't really need to worry about current limiting the resistors since we won't leave them on enough to start drawing too much current. In your setup, you are trying to run more than one LED full blast, which would start limiting you where the MCU can't draw any more current.

Humberto

July 19, 2011
by Sinabyte
Sinabyte's Avatar

Thanks, that makes sense. I will try putting some new code in an interrupt and pulse the LEDs instead of torturing them with non-stop current in the main loop. Some basic math and experimenting should get me firing them at an appropriate cycle. Hopefully i didn't damage anything from flailing about and shorting wires.

I was using the LED Array Kit as a guide, including the code, since I guess I like to do things the hard way somewhat from scratch. Thanks again to both of you.

Post a Reply

Please log in to post a reply.

Did you know that the sparks present in motors can be dangerous for your microcontroller and other electronics? Learn more...