# Why is my transistor switched output so low?

Help needed! I am using an Arduino Nano and a general purpose npn (2n2222a) transistor to provide a 12v signal to a low current 12vdc load in an automobile. The Arudino code is set to pulse D2 at bootup/startup for .5 second. The PWM output setting was 255 (since switched to digitalWrite). However, the switched output measures only 4.5v (expected close to 12v). What am i doing wrong? Applying 12v+ directly to the black box works. The purpose is to simulate a temporary button push in the car so an auto function is enabled.

• the black box is raising the voltage on the emitter ... that in turn raises the base voltage necessary for transistor to turn on ... the nano is not able to supply that voltage .... connect the emitter to GND ... place black box at the collector .... this has been beat to death here and many places ... do research about driving a motor or solenoid or lamp with an arduinp Oct 19, 2020 at 23:58
• I did do research, and found this circuit (4th circuit, emitter-follower) which looked close to my desired application: electronics-tutorials.ws/blog/…. Oct 20, 2020 at 5:07
• the problem with your circuit is that D2 does not rise to 12 V Oct 20, 2020 at 5:11
• How much current is needed for your black box with 12 V supply? Oct 20, 2020 at 5:11
• not much current - it's supplying a signal to an auto control unit simulating a short button press - a few milliamps at a guess. Oct 20, 2020 at 5:15

The problem is that you are using an NPN transistor as a high side switch.

The voltage at the emitter of the transistor will always be about 0.7V below the voltage at the base. The "high" output from the Arduino is 5V. The emitter will be at about 4.3V.

Have a look at the Wikipedia "emitter follower" page. The emitter follower is also called a common collector circuit. That explains the "problem" in more detail. It is only a problem in so far as it is not the correct solution for your task.

You need to use a "common emitter" circuit.

This usage is commonly called a "low side switch."

That would look like this:

simulate this circuit – Schematic created using CircuitLab

If your black box really needs its input pulled up to 12V, then you would do something like this:

simulate this circuit

The resistor values and transistor part numbers are place holders. The values of resistors you will need depends on the transistors you use. The transistor selection will depend on how much current you need to deliver to the black box.

I see in a comment that your black box only needs a few milliamperes. In that case, the shown transistors should work just fine. The resistor values may be a little too high, but I think they'll be OK.

1. The Arduino has PWM outputs, not PCM.
2. The output voltage for your black box will be pulsing if you use any PWM value lower than 255. Your black box probably won't like that, and your voltmeter won't read a correct voltage.

You should use D2 as a digital output rather than PWM. Just turn it on or off rather than fiddling with the PWM duty cycle. Use "digitalWrite" instead of "analogWrite" on pin D2.

• Thanks, i switched to digitalWrite in the code. Oct 22, 2020 at 23:52

The 2N2222 is an NPN device. Skipping all of the physics involved, that means that (in your application) it will sink current as a low-side switch, but not source current as a high-side switch.

If you want a high-side switch, you should find a PNP transistor. In this case your Nano pin will sink current from the transistor's base terminal.

I would recommend you stick with the 2N2222, but make two changes:

1. Connect your "black box" between the positive terminal (+) of your 12V supply, and the collector terminal of the 2N2222.

2. Reduce the size of your base resistor from 10Kohms to 1Kohms

• The ground side of the black box is not available. The black box (control unit) circuit has to supply +12v to simulate the switch press. Oct 20, 2020 at 5:05
• @Seamus: An NPN transistor will quite happily source current as a high side switch. Tha'ts what it does - it is an emitter follower. What it can't do is to provide a voltage at the emitter that is higher than the base voltage.
– JRE
Oct 20, 2020 at 8:42
• No, Seamus, I'm not looking for a "chat room." I spend most of my time on the electrical engineering stack exchange. The statement "but not source current as a high-side switch" is incorrect. As the original question shows it, the 2N2222 would try to deliver all the current available from the 12V source to the black box. If the black box were a short circuit to ground, the 2N2222 would quickly burn out from trying to pass many amperes of current from the car battery. So much for "not sourcing current."
– JRE
Oct 20, 2020 at 9:17
• As used, the black box won't consume much current (there's a comment that says it only needs a few milliamperes.) That doesn't change the fact that an NPN transistor used as a high side switch can quite happily source current from its emitter.
– JRE
Oct 20, 2020 at 9:50
• And an NPN transistor will deliver current as shown in the question. Or haven't you tried it?
– JRE
Oct 20, 2020 at 10:19

What I have thought about is using an opto-coupler

Connect the Arduino pin output to pin 1 through 330 ohms resistor, pin 2 to ground of Arduino, connect pin 4 to Vcc of 12 V and finally connect pin 3 to the black box load.

Try this configuration

Since black box only needs few milliamps as you said May be the transistor is not saturated since base current has to go through the black box load opto-coupler s have no base current instead they use photons

Here is the circuit diagram

5 V supply looks like the Arduino pin D2 and lamp is the black box load. This is 4N35 example

• The opto coupler looks like a good idea. The part is cheap and small. If it can switch 12vdc at a few ma, it looks like the simplest solution. Oct 22, 2020 at 15:18

ok, so i chose the 2 transistor high side circuit as i had the needed pnp transistor laying around. Works great, thanks everyone for your help. The trace (5v/div) shows the Arduino signal at 5v and the circuit output at 12v - perfect!