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.

  • \$\begingroup\$ What do you mean by "configure the pins"? As long as the pins are capable of sinking sufficient current, setting them to low will cause the LEDs to light. \$\endgroup\$ Commented Sep 30, 2014 at 10:16
  • \$\begingroup\$ Thx for your reply. And thx for the tip about the electronics department (didn't know this existed). I mean with configure the pins should it be input or output? \$\endgroup\$
    – Daan Mouha
    Commented Sep 30, 2014 at 10:22
  • \$\begingroup\$ Are such 'PINSEL' details not in the controller user manual? \$\endgroup\$ Commented Sep 30, 2014 at 10:40
  • \$\begingroup\$ @DaanMouha Output. \$\endgroup\$
    – meaning-matters
    Commented Sep 30, 2014 at 10:49
  • \$\begingroup\$ Whenever you drive something, it should always be an output, regardless of whether you intend to drive the pin high or low. The main concern here is the MCU pins, not the LEDs. You'll have to check the MCU spec and see how much current one pin can deliver, then see if your solution is feasible - you might have to add additional transistors (or equivalent) instead of driving the LEDs directly from the pins. Apart from that, if you drive a LED through PWM, you have to adjust the circuit so nothing breaks in the worst case, ie 100% duty cycle. \$\endgroup\$
    – Lundin
    Commented Sep 30, 2014 at 10:58

1 Answer 1


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).

  • \$\begingroup\$ I need to many LEDs so I'm going to use the 24 channel 12 bit led driver of Adafruit and adjust their library for it so I can use it in a regular µcontroller and not an Arduino. \$\endgroup\$
    – Daan Mouha
    Commented Nov 14, 2014 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.