Arduino project. I have a breakout board and have pulled the voltage in (vin) and ground to the board. I have a transistor with emitter to ground and a PWM pin from the arduino to the base via a 10k resistor. I take my meter and go from vin to the collector.
If I am using USB as the power source, I can vary the voltage as expected. Cycling the PWM from 0 to 255 yields 0 to 4ish volts.
If I am using an external power supply (10 volts, 1000ma), I can vary the voltage, but it never goes to 0. The range is something like 2 volts to 8 volts. 8 is fine, but I need 0 on the bottom end. analogWrite(pin, 0) and digitalWrite(pin, LOW) both yield the 2 volt trickle.
The transistor I purchased at Radio Shack. It is an NPN 2222a.
I've never metered it before or tested it but since a transistor is current driven perhaps its no current flowing yet 2v from the npn junction voltage drop?
maybe a mosfet would get you the 0v you need
You haven't described the 'load' between Vin and the collector.
"I take my meter and go from vin to the collector."
Take your meter and go from the collector to ground.
Use a smaller resistor to control the base, and turn the transistor on more.
Vbe will be around 0.7V, so
(5V - 0.7V)/20ma = 220 ohm.
However, Vce across the transistor will never be much lower than ~ 1 diode voltage, ~0.7V.
I think a 2n2222a needs 50mA to drive it full on with a 150mA load.
If you want lower, you need a N-channel MOSFET with a low Rds.
Then the voltage will be current * Rds.
If Rds is like 50mOhm, the voltage will be quite low. But never 0.
R1 = 35 / ILoad, where ILoad is given in amps and is the current resulting from driving the load with (V+ - VCE), which in your case would be about 9.8V
And remember, this circuit will not invert the PWM signal. In other words, when the PWM signal is high, ILoad will flow.