Transistor works as a resistor?

Hello,

Im trying to hook up a transistor to Arduino, but no matter what type of resistor I use, whenever I do a digitalWrite HIGH or analogWrite 255 to the PWM pin, the output voltage is always lower than the input.

For instance, I have an input of 12V DC but the output is never more than 4V. I've tried it with the following transistors: - TIP122 - MPSA42 - BC548

Am I doing something wrong or is this how Arduino works and will I never be about to get the 12V out of the transistor?

The very last thing you should think of doing is showing your circuit so that everyone will know what you're doing.

Yes, you are doing something wrong.

If you want a better answer, please post your schematic.

Does it look like this?

If not, you are doing it wrong.

Incidentally if you wire it something like Polymorph's diagram, it will work, but when the Arduino in is high. the "output" of the transistor will be low, and so the voltage will be across the load, here shown as a solenoid.

Yes, that is important to realize. However, an ON output is ON for the solenoid or load. If you need a high side driver, an NPN is not what you need.

But if you are using an NPN transistor, and especially when you are controlling a voltage greater than 5V, that is how you connect it.

Here's some ways that would only give about 4V on the output: Emitter Follower Circuit

Perhaps your using one of these?

PaulE: Am I doing something wrong or is this how Arduino works and will I never be about to get the 12V out of the transistor?

With an NPN transistor correctly wired, you won't get "12v out". What you will get is 12v on the collector if wired as in the previous diagram. When the IO pin goes high the collector will go low and allow current through the coil.

The transistor acts as a switch to ground.

The only way I can see that you would be getting 4v out is if you have the IO connected to the base, the emitter to 12v and the collector to relay with the other side of the relay to earth. With this arrangement you have the a reverse biased junction (base emitter) and the equivalent of a diode in series ( base emitter junction) with the coil to earth.

Weedpharma

The emitter follower configuration isn't usually used for switching as its inefficient. It is often used for buffering an analog signal as the output impedance is low.

Sometimes you actually want an extra voltage drop of about 1V, in which case it can be useful for switching, but if you want to boost the voltage you must use the normal common-emitter circuit where the load is on the collector - such a configuration amplifies both voltage and current.