Pages: 1 [2]   Go Down
Author Topic: Transistor, PWM and LEDs  (Read 2876 times)
0 Members and 1 Guest are viewing this topic.
Cumming, GA
Offline Offline
Edison Member
*
Karma: 20
Posts: 1655
Ultimate DIY: Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Quote
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:

luminosite = map(analogRead(lightPin), 0, 1023, 0, 255);

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

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


* mydrawing.jpg (35.32 KB, 579x789 - viewed 24 times.)
« Last Edit: June 03, 2012, 07:24:42 pm by pwillard » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34213
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 118
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

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

Cumming, GA
Offline Offline
Edison Member
*
Karma: 20
Posts: 1655
Ultimate DIY: Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: 1 [2]   Go Up
Jump to: