Driving 40 led's with MCU - Page 1
Forum section: electronics / beginners

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: April 09, 2015, 10:43:30 am
content: I have 40 led's connected to each pin of MCU. MNow MCU can't drive each led. So waht I am thinking of right now is to drive 2n7002 gate with each pin which will drive the led. In this I have to connect 40 2n7002.Any other better solution for this.1. MCU is 3.3V powered.2. Have to individually control each led.

author: Psi
author_rank: Super Contributor
timestamp: April 09, 2015, 11:03:15 am
content: Do you have 40 leds on each pin or 1 led on 40 pins?If you want to drive lots of LEDs google "led multiplexing"

author: mcinque
author_rank: Unknown
timestamp: April 09, 2015, 11:16:47 am
content: if you would have 40 MCU free pins and the matter is only about the current that the MCU can't provide, you could use small fets (like ZVN) to drive each single led, otherwise if it's a matter of free pins you could use shift registers.

author: mariush
author_rank: Super Contributor
timestamp: April 09, 2015, 11:20:41 am
content: The microcontroller can't provide enough power to light up 40 leds at the same time.There are some limits in regards to how much power can be provided on each pin, and how much power can be provided through all pins - for example, each pin could output 10-20mA but the microcontroller may only be able to do 100-150mA through all pins.You can use transistors or mosfets to turn on or off leds... mosfets would be better because with transistors you'd still use a bit of power (under 1mA for each transistor) to turn the transistor on and off. Note that normally you'd still have to use at least one resistor to limit the current going through the leds, you don't want to limit the current using the transistor.If you don't want to use additional parts, you can do multiplexing ... for example see tip 2 in this collection of tips and tricks from microchip:http://ww1.microchip.com/downloads/en/DeviceDoc/01146B.pdfYou can easily expand this trick to 40 leds and to work around the limitations of the power, you can add code to turn on and off leds very fast so that at any time, only 10 or 20 out of those 40 leds are turned on.A proper way to do it would be to use led drivers, there are chips that can control up to 16 leds.. the microcontroller simply sends a series of bits to the chip and the chip takes care of limiting current to each led and turning them on and off according to the bits you send.Other solutions, cheaper and without complexity, that are normally used are shift registers (send stream of bits to shift register, shift register then turns on or off 8 pins to which you can connect leds) or darlington arrays like uln2003a for example (google it and read datasheet).

author: Zero999
author_rank: Super Contributor
timestamp: April 09, 2015, 02:14:25 pm
content: How much current do the LEDs need to be bright enough?Modern LEDs are often bright enough with 1mA so you might be able to connect them to the MCU outputs via resistors alone.

author: macboy
author_rank: Super Contributor
timestamp: April 09, 2015, 02:24:38 pm
content: I agree about using a low current. Many modern LEDs are very bright at just 1 or 2 mA.If you need more current and don't want to mess around with 40 FETs and 40 current limiting resistors, then you can try an LED driver IC like the TLC5940. These can be had for roughly $1.50 each and drive 16 LEDs each, without needing per-LED series resistors. They use an SPI serial input and can be cascaded, so you can drive 40 (or many more) LEDs with just 3 pins of your micro.