LEDs using uC's I/O pin to control

Thread Starter

Intorvert

Joined Nov 9, 2009
3
I would like to control 50 LEDs using uC. LEDs are designed to show 5 different symbols each used 10 LEDs.
The uC output is 5V but the external battery that I wanna use it 12V. So I need something in between to control.
1)What should I use in between?

I have tried to use 2N3904 BJT to control the LEDs, but I found out my connection is something wrong.
I have used the external 5V instead of uC output for testing.
Please Help.
--Rex--
 

SgtWookie

Joined Jul 17, 2007
22,230
I would like to control 50 LEDs using uC. LEDs are designed to show 5 different symbols each used 10 LEDs.
The uC output is 5V but the external battery that I wanna use it 12V. So I need something in between to control.
1)What should I use in between?
Transistors or logic-level MOSFETs should work.
It depends upon how much current your LEDs require, and how many are in a circuit.

What is the typical Vf @ current rating for your LEDs?

I have tried to use 2N3904 BJT to control the LEDs, but I found out my connection is something wrong.
I have used the external 5V instead of uC output for testing.
I see that you have used a 10k resistor between the 5v supply and the base of your transistor. That might be OK if it were a Darlington, but not for a single bjt (bipolar junction transistor).

A typical microcontroller might be able to source 20mA max from an I/O pin.
With that much current, the base-emitter voltage of a 2N2904 transistor may be up to 0.8v or so. Rather than going for maximum current output on the uC I/O pin, let's just aim for 10mA.

Let's start by subtracting the be voltage from Vcc; 5v-0.8v = 4.2v.
In order to get 10mA current across a 4.2v drop, you'll need:
R = E/I (Resistance = Voltage/Current)
R = 4.2/10mA
R = 420 Ohms. The closest standard value of resistance is 430 Ohms.
In this case, you could go down to 390 Ohms if you wished.
 

Thread Starter

Intorvert

Joined Nov 9, 2009
3
Thank you..
In that case, I am going to use EIGHT DARLINGTON ARRAYS, since my college suggested me to use that too.

Currently I have ULN2803A with me to test out the LEDs' control.

My design have to used many different colour LEDs, currently now I am just trying with typical Vf of 2.1V LED.

The image that is attached previously has two hand drawn circuist, but I can't understand how the top diagram works... why LEDs have the brightness that i need why i connect to the emitter rather than collector in the top diagram.
 

SgtWookie

Joined Jul 17, 2007
22,230
Thank you..
In that case, I am going to use EIGHT DARLINGTON ARRAYS, since my college suggested me to use that too.

Currently I have ULN2803A with me to test out the LEDs' control.
ULN2803's are good. They have built-in 2.3k base resistors, so you can connect the inputs directly to your uC; no need to use individual resistors on the bases.

Note that you will have an increased Vce over standard BJT's though. With light loading, you'll probably see about 0.6v between emitter and collector.

My design have to used many different colour LEDs, currently now I am just trying with typical Vf of 2.1V LED.
That is not good.

You should add up all of the Vf's of the LEDs in a single string to determine the current limiting resistor that is required. That means you will need to use each LED's typical Vf at the rated current; but the rated current will be the lowest common denominator.

Newer red LEDs might have a Vf of 2v or higher @ 20mA. Green and yellow might be 3v. Blue and white may be around 3.4v to 4v.

If you don't have the LED specifications, you will need to test them individually, putting a constant 20mA current through them and measuring their Vf.

When you add up all of the Vf's in a series string, don't forget to add in the Vbe of the ULN2803 before subtracting the total from Vcc (12v). The sum of the LED's Vf's + Vbe should be at least 1v less than your Vcc.
Rlimit >= (Vcc - (VfLED1 + VfLED2 +... Vbe)) / DesiredCurrent(typically20mA)
Rlimit >= (12v - (2.1v + 3v + 3.8v +... 0.6v))/20mA
etc
The image that is attached previously has two hand drawn circuits, but I can't understand how the top diagram works... why LEDs have the brightness that i need why i connect to the emitter rather than collector in the top diagram.
The top diagram is connected as an emitter follower. You won't be able to use the ULN2803 in that configuration.

The bottom diagram is using a transistor as a saturated switch. However, the base resistor is much too large for a single bjt, if the collector will be sinking 20mA. It is even too large for a Darlington transistor when switching from TTL levels.
[eta]
Also, the LED current limiting resistor in the lower schematic is much too large.
If all of the LEDs had a Vf of 2.1, and you are using a Darlington transistor, then:
Rlimit >= (12v - (4 x 2.1+0.6)) / 20mA
Rlimit >= (12 - 9) / 20mA
Rlimit >= 3v/0.02A
Rlimit >= 150. 150 is a standard value of resistance.
Bookmark this page: http://www.logwell.com/tech/components/resistor_values.html

Then calculate the wattage dissipated in the limiting resistor:
P = EI
P = 3v x 20mA
P = 0.06 Watts. Double it for reliability; 0.120 Watts. You could use a 1/8 Watt resistor or larger.
 
Last edited:

Audioguru

Joined Dec 20, 2007
11,248
The top drawing has the C and E of the transistor connected backwards.

The transistor is not an emitter-follower. It cannot drive four LEDs in series as an emitter-follower with a source voltage of only 5V.

Didn't the OP say that the top drawing has brighter LEDs than the bottom drawing? Then the C and E of the transistor are the opposite to what is drawn.
 

SgtWookie

Joined Jul 17, 2007
22,230
Yes, it is connected backwards. That's what I get for posting when it's late and I'm tired. :rolleyes:.

Any way you look at it, the upper schematic has a mistake and is not complete (no reference for the +5v source), and the bottom schematic is not complete (no reference for the +5v source).

If on the bottom schematic, if the negative side of the 5v battery were connected to the junction of the emitter and 12v battery negative terminal, then there would be a complete current path for the 5v supply.
 
Top