How to drain power with pins for led matrix on atmega32 instead of using a led driver

atmegaavrc

I want to make a led driver without the tlc594 series.
I use the atmega32 of which I can use 1 PWM pin.
The PWM pin will be connected to the base of the transistors.
With the PWM pulse I can dim the leds.

My question is how to configure the pins so that:
1) Pin is high, led wont burn.
2) Pin is low, led will burn.

I added a simplified scheme, of the led driver with a led matrix, so you can understand my situation.

Simplified led driver scheme.

Thx for the help.

Best Answer

My question is how to configure the pins so that: 1) Pin is high, led wont burn. 2) Pin is low, led will burn.

If you configure a pin as output, setting it to low will sink current and setting it to low will source current. As long as the Vcc supplying your LEDs is the same as the controller Vcc, you circuit should work as expected.

The atmega32 can safely sink/source about 20mA per IO. However, there are limitations regarding the total maximum per port and for all ports combined. It depends on the package type. For PDIP its about 100mA max per port and 200mA max total. Take a look at the "DC characteristics" section in the data sheet.

So using 4 LEDs as illustrated should work fine (assuming about 20mA per LED).