I am trying to make an ATTINY85 control an LED strip for an aquarium. The strip has a +12v pin for the white LEDs, a +12v pin for the blue LEDs, and a common ground pin.
0After reviewing many schematic diagrams on google, it appears that a NPN transistor has to have the emitter connected directly to ground, but that is not possible in my case since I need a positive voltage to control the light. I considered using a PNP transistor, but that would make coding considerably harder, and waste power since I want the light to be turned off most of the time, so I would rather use a NPN transistor if possible.
If it helps, I am currently using a BC337 transistor, as it is rated for 800ma and my light is 200ma max. I do have some other types on hand, so I can substitute is needed. Thanks in advance.
You seem to not fully understand how transistors work.
If an NPN-transistors base is grounded the NPN-transistor is not conductant and will not draw any current
If an PNP-transistors base is connected to Vcc (the "plus-voltage" the PNP-transistor is not conductant and will not draw any current
You can switch on/off any LED, LED-stripe either with a NPN-transistor or PNP-transistor
the only thing to make a LED or LED-stripe emmitting light is that there is the right voltage-difference
between LED-anode and LED-cathode and that you connected anode to "plus" and cathode to the opposite
NPN-transistor: emitter connected to ground, anode connected to Vcc, cathode connected to collector of NPN-transistor
PNP-transistor: collector of PNP-transistor connected to Vcc anode connected to emitter of PNP, cathode connected to ground
You seem to not fully understand how transistors work.
If an NPN-transistors base is grounded the NPN-transistor is not conductant and will not draw any current
If an PNP-transistors base is connected to Vcc (the "plus-voltage" the PNP-transistor is not conductant and will not draw any current
You can switch on/off any LED, LED-stripe either with a NPN-transistor or PNP-transistor
the only thing to make a LED or LED-stripe emmitting light is that there is the right voltage-difference
between LED-anode and LED-cathode and that you connected anode to "plus" and cathode to the opposite
NPN-transistor: emitter connected to ground, anode connected to Vcc, cathode connected to collector of NPN-transistor
PNP-transistor: collector of PNP-transistor connected to Vcc anode connected to emitter of PNP, cathode connected to ground
I was aware of how transistors work, but I don't know if I can set up my circuit using the PNP schematic but with an NPN transistor. Basically, I would have to connect the LED strip positive to the transistors collector, and the LED strip ground to ground. Is this possible though? As shown in your NPN transistor schematic, the emitter connects directly to ground. Here is my schematic
on what I want to do:
I can't because I have 2 LED channels that I have to control independently, but they share a common ground. If I connect them between the collector and +12 volts, I will lose the ability to independently control the LEDs.
NPN-transistor need a minimum 0,7V higher voltage on the base than the emitter has to become conductant.
If you connect the LED between emitter and ground all the voltage-drop happens between ground and emitter. This means your base would have to be on + 12,7V to make the NPN-transistor conductant.
That is the reason why it does not work with an NPN-transistor.
The solution is to use two transistors
duckduckgo is always worth a five minute search
Thank you. One more question. How do I calculate the resistor values? I am still new to this kind of math, so I don't know what Ic=Ib * hfe means or what values to put into the variables. I can do algebra and solve an equation like this, I just don't know what values to use.
Your LED-strip is for use with 12V. This means the current-limiting resistors in series with the LEDs are inside the LED-strip.
This means you need no extra resistor in series to the LED like shown in the schematic for a single LED
The base of the transistor needs a current limiting resistor
hfe is the current-amplifying factor
your leds draw 200 mA. This means through the base must flow a current of
200 mA / hfe
The datasheets of transistors provide diagrams for this. But not all datasheets the one for the BC327 is rather poor with diagrams.
As you are just switching fully on fully off the value must not be calculated carefully.
You just have to make sure that the base-current is high enough to make the transistor fully conductant.
Me personal I do not calculate these currents I measure them.
Starting with a high resistance = very low current and then reducing the resistance until the needed current through Collector-Emitter is reached. Then I look on the base current how much is it?
In most cases the base-current is in the range of less of 5 mA. Example 0,7 mA fo a certain base-resistor then I will go up to drive the base with 2 mA just to make sure the transistor is fully conductant
When using the two transistor circuit the current through the NPN can be pretty low as the NPN only drives the PNP
at 10 kOhm the current through R3 will be
12V / 10000 = 1,2 mA
So for R1 the 1 kohm is good
Even at 1 mA into the base of Q1 (NPN) the transistor can drive more than 100 mA
Read the text below the schematic of this link already given above
R2 being 1k means the base current for Q2 is -12mA (giving ~400mA collector current).
This is a bit high, but always measure Vce of Q2 to see if it saturated; you can then increase R2 until Q2 starts to show it’s coming out of saturation.
Attiny85 i/o pin max current is 40ma
Your led strip is 200ma
looking at your mentioned voltages in circuit and datasheet of bc337 gain will be around 100.
200ma/100=2ma at the base
Considering drive voltage of attiny85 of 5v you gonna put 2.15K-2.5K at the base.
Note tho even bc337 max current is 800ma its power dissipation is around 600mw max!
I would pay attention to power dissipation because bjt is very temperature dependent and the to-92 package isnt easy one to cool down.
200 mA is not that much. But you must make sure that the voltage-drop across the transistor is small = transistor must be in the area of lowest possible saturation voltage
example:
Voltage-drop across C-E of transistor: 0,2V saturation-voltage * 0,2 A = 40 mW power-dissipation
Voltage-drop across C-E of transistor: 0,8V saturation-voltage * 0,7 A = 560 mW power-dissipation
I did a quick dudckduckgo again
and came up with this website
It shows a rarely used circuit as it is the common-base circuit
In this case the current-limiting resistor R1 is really important because without this current-limiting resistor the IO-pin would have a too heavy load
No it will not!
because with a single NPN-transistor the shared common-cathode will light up always both LED-colors white and blue when ever one of both transistors is switched on.
And what is really impossible as explained above is to insert the LED-strip between emitter and ground