Go Down

Topic: Unexpected behavior with 2N2907 PNP transistor (Read 919 times) previous topic - next topic

jeff_lamarche

I'm trying to run a bank of high-power LEDs from the Arduino (well, actually, an ATTiny85, but prototyped on Arduino and programmed using the Arduino IDE). I'm taking input from a potentiometer and using that to allow the LEDs to be dimmed. I'm using a 2N2907 transistor off of PWM pin because the current coming off the chip isn't sufficient to drive the whole bank of LEDs. It's kind of working, but instead of dimming from off to high, it's dimming from bright to really really bright. Manually setting the pin to 0 or LOW doesn't turn the pin off, just dims it down a bit, though physically removing the wire from pin 2 of the transistor does shut down the LEDs.

It's setup like this:

Pin 1 of the transistor is connected to VIN (9V battery)
Pin 2 connects to Pin 11 when using Arduino, or Pin 0 (IC pin 5) when using the ATTiny85, both of which support PWM
Pin 3 is connected to ground

I've checked the potentiometer, and am getting the correct expected value as input from it. I've also made sure that the output values I'm sending to the transistor range from 0 to 255. The spec sheet for the 2N2907 seems to indicate it can handle a 9v DC.

I suspect I'm doing something boneheaded. This is my first attempt to use transistors to run something requiring higher voltage and I'm relatively new to hardware and microcontrollers. If anyone has an idea what I'm doing wrong, I'd appreciate being pointed in the right direction (and it's okay to point it out if I'm doing something dumb).

Thanks in advance!

johnwasser

Isn't your load connected between pin 3 and Ground?

To turn the PNP transistor off I think you have to feed 9V into the Base (pin 2).  As you lower that voltage the current gets progressively higher and the transistor turns on.  That explains why 5V turns the transistor on some and 0V turns it on more.

Most people use NPN transistors between the load and Ground.  0V turns the NPN transistor off and +5V turns it on.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

jeff_lamarche

So, a little more research and experimentation, and it looks like I figured the answer out on my own. Figured I'd leave it here for the benefit of future searchers.

The answer is that I used a PNP transistor when I should have used an NPN. I swapped in a PN2222 and reversed the wiring to the LEDs, and now it works as expected.


jeff_lamarche


Most people use NPN transistors between the load and Ground.  0V turns the NPN transistor off and +5V turns it on.


Yes, you are right. Just my inexperience showing. Thanks for the info.

Go Up