Transistor as switch questions?

Hi

I need to control 4 panels of 4 leds with the Arduino, I could not simply connect them up to the io pins as 44=16 and 1615ma=240ma. Therefore I plan on using a transistor as a switch to control each of the 4 panels so 4leds*15ma = 60ma a panel.

I plan on using the BC548B transistor (http://www.philohome.com/sensors/gp2d12/gp2d12-datasheets/bc548.pdf) which has a gain of approximately 50x at 1ma so I need to supply it with roughly 1.2ma. Are my calculations correct? Will the transistor run ok with this little base current?

My next possibly stupid question is: The Arduino supplies 5v via it digital io pins and the base max voltage is 5V so do I need to be worried about that or does the resistor stop the 5V from being reached, I presume the latter.

So if I need 60ma flowing from collector to emitter and I have a 9v battery connected and the voltage drop of the led panel is 3.3V, I should have a 100ohm resistor between the battery and the collector?

Thanks in advance :slight_smile:

You can use LED drivers or high-current shift registers, as they generally have 8 or 16 outputs and need a few Arduino pins to control them.
If you want to use transistors, you'll need one transistor for each LED, and many pins (or a low-current shift register).

But how do you control the LEDs? Are the 4 LEDs on a single panel switched together?

Depending on how you want to control them, one solution might be better than the other... But if you want to go the easy way, look for a LED driver.

I already have the transistors and the Arduino will be completely enclosed so this is a one time calculation. The leds are one colour and are connected in parallel, so I have two wires (+/-) that control the panel.

I meant : are you controlling each LED independently or all at onces, like they are all ON or all OFF and that's all?

To drive transistors into saturation, you do NOT use the small signal beta.

From the datasheet (ctrl-f and type in "saturation")

VCE(sat) Collector-Emitter Saturation Voltage
IC = 10 mA, IB = 0.5 mA 0.25V
IC = 100 mA, IB = 5.0 mA 0.6V

So this transistor is spec'd for the base current to be at least 1/20th the collector current.

Some older transistors like the 2N2222 and 2N3904/2N3906 are spec'd for 1/10th.

So if I need 60ma flowing from collector to emitter and I have a 9v battery connected and the voltage drop of the led panel is 3.3V, I should have a 100ohm resistor between the battery and the collector?

resistance - Correct formula for LED current-limiting resistor? - Electrical Engineering Stack Exchange

Maybe instead of asking someone for a fish, you should ask them how to fish....

If the base current needs to be at least 1/20th I will go with 1/15th to allow for a bit of a "fudge" factor. Therefore I need to supply (60/15) = 4ma to the base.
Here is the bit I am not 100% sure on: If the gain is 50x but the base current is 1/15th, what size resistor should I use to connect the battery to the collector. I think it should be 100ohm as detailed below:
To calculate the led resistor: ((9-3.3)/60ma)= 0.095 = 95ohm resistor = 100ohm resistor (closest I have).

The leds are one colour leds, and all of the leds in a panel will be switched on or off.

Thanks

Yes, better to drive it slightly harder than not quite as hard.

The gain does not enter into it.

To size the LED resistor, you need the supply voltage minus the LED voltage and the VCE voltage drop, divided by the current desired. It looks like you have done just that.

How do I know the voltage drop of the transistor to calculate the resistor value for the Arduino output?

How do I know the voltage drop of the transistor to calculate the resistor value for the Arduino output?

You could read the datasheet

Turns out that I need to look for Vce and not the words voltage drop, the Vce is 2V.
So: ((5-2)/4ma)=750 Ohms

I have created a very crude diagram of the proposed circuit based on my calculations, does it appear to be correct?

Thanks for all of your help.

Hardly, your battery's backwards and you have both terminals shorted to the anode of the led, not to mention your led current limiting resistor is not in series with the led. It is connected to the emitter.
Use the following format but substitute the Vcc value you are using.

transistor led circuit

May I suggest that in the future you just pick up a pen and draw schematic and take a photo of it with your cell phone and post it ?

Thanks for the error locating and advice, next time I will definitely just pick up a pen! New version is attached.

STILL WRONG ! Why are you putting the 100 ohm current limiting resistor there ?
It goes in series with the led, not connected to the emitter . (it goes between the collector and the led cathode).

The word you are looking for is "saturation". Here are screenshots from the datasheets for the 2N2222 and 2N3904 bipolar transistors. Note what VCE is under different current conditions, and that when using them as a switch, IBE should be no less than 1/10th of ICE.

Some newer transistors are rated for IBE no less than 1/20th of ICE in saturation.

Wait, why am I saying this again?

2N2222SaturationIV.gif

2N3904SaturationIV.gif

That's about a 10:1 to 15:1 ratio in the base current and collector current. (SAT:Normal)

So should my resistor be 750 Ohms? I got the Vce from the image attached. As you say that "IBE should be no less than 1/10th of ICE.", is my 1/15th figure still acceptable?

You're not paying attention. The 100 ohm current limiting resistor belongs in between the
led cathode and the transistor collector. Fix that first and then we can talk about something else. There is no point in continuing until that's done. If you had even looked at Reply#14 you would realize that.

Schematic updated, third time the charm!

"You're cleared for take off on runway 37 L..."