Weird behavior using Transistor
When you connect the base to 5-V output and the collector to 12 V with a load between the emitter and ground, this would be called "emitter follower". The voltage on emitter will be "following" the base voltage minus about 0.7 V, which you perfectly determined. To switch your load to full 12-V, you need to connect the emitter to ground, and your load between the collector and +12v power rail. An get some limiting resistor (100-200 Ohms) between the MCU output and the transistor base.