Go Down

Topic: Transistor, PWM and LEDs (Read 3 times) previous topic - next topic


Jun 04, 2012, 01:52 am Last Edit: Jun 04, 2012, 02:24 am by pwillard Reason: 1
However, I don't understand how to "send" only 5mA base current when I have no control over the intensity of the current sent out by the atmega chip.

That *is* the primary job of a resistor in a circuit and what the recommended resistor will do in the circuit we discuss.

Sometimes we forget that we were ALL new at something, sometime and advice of that nature about base current can be more defeating than a real lesson should be.

To me, that statement is just noise that gives an excuse for doing shoddy work.  When working with transistors, there is no excuse for being loose and free with base current unless you have a supply of spare parts.   Any good advice  about base current can hardly be "more defeating than a real lesson should be".

You will note that I said "is not best practice".   I did not say the words "won't work".  However, I do intend to imply that ignoring advice (and ohms law) can mean that in some cases a device "lives fast and dies young".

Also, as grumpy mike has said in the past... just because something works... does not mean it's not doing damage.  Getting a concept wrong on a small scale can be really costly if in a final project you have replicated a misunderstanding many many times.

As for OP's most recent drawing and results.... if we are to trust your drawing... it won't work with your LED's in backwards.  As for your results... I still say... wiring error.

I used your code and the circuit you SHOULD be using... and I get the expected results...BUT only AFTER I make your MAP statement look like this:

[font=Verdana]luminosite = map(analogRead(lightPin), 0, 1023, 0, 255);[/font]

So, since you get a different result... your wiring must be incorrect.

IE; When Light level goes up, the LED gets brighter...


And for the photocell

This is the same circuit as the transistor, is this correct?
As mentioned the LEDs are shown the wrong way round.
Using a transistor like this to drive an LED will work in the same manner as connecting the LED through a resistor from the arduino output to ground.


Latest developments: I replaced the CTPN2222 transistor with a pin for pin dropin BC547.
And to my surprise, the logic is no longer inversed.
I am glad but I still don't understand what is the difference between these two transistors that would make the logic inverted in the PN2222 and not in the BC547?
I am a total amateur at electronics and all things related. I have no education in the matter other than self taught.

Please factor this in


Sadly, not really a 100% drop in replacement.

BC series have a different pinout than JEDEC based parts,   Jedec = EBC versus BC = CBE, which means you had the transistor in backwards.

Go Up