Why is my transistor switched output so low?
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 &quot;high&quot; output from the Arduino is 5V.  The emitter will be at about 4.3V.
Have a look at the Wikipedia &quot;emitter follower&quot; page.  The emitter follower is also called a common collector circuit. That explains the &quot;problem&quot; 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 &quot;common emitter&quot; circuit.
This usage is commonly called a &quot;low side switch.&quot;
That would look like this:



simulate this circuit &ndash; 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.

A couple of additional points:

The Arduino has PWM outputs, not PCM.
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 &quot;digitalWrite&quot; instead of &quot;analogWrite&quot; on pin D2.