Can't get 0 volts

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.

Can anybody help me get 0 volts?

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

Do you have the ground from your 10V source tied to the ground on Arduino?

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.

For a 2N2222A at IC=150 ma the VCE should be less than .3V, typically I find they often go lower than 0.2V.

Also, at IC=150ma, gain is greater than 100, so you can easily drive it well into saturation with IBE @ 10-15 ma.

What are you trying to drive with this?

I'm not sure the OP has a load other than the voltmeter - that would explain the apparent problem.

Okay, method 1.

Have a look at the attached circuit.

Select R2 for the required ILoad.

Then select R1 = 10 x R2 x (VPWM - VBE) / (V+ - VCE sat)

Given that VPWM=4.2V, V+ = 10V, VBE=0.7V, VCE sat=0.2V then:

R1 = R2 x 3.6, ...give or take...

And remember, this circuit will invert the PWM signal.

Method 2.

Have a look at the attached circuit.

Select R1 = 10 x (VPWM - VBE) / ILoad

Given that VPWM=4.2V, VBE=0.7V, then:

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.