Using NPN transistor as switch
It looks like you need a current limiting resistor between your output pin and the transistor base (assuming you didn't omit it on purpose, for brevity). Without the resistor, when you set the output pin to HIGH, you are causing a short-circuit to ground. That may damage the pin, if it hasn't done so already.

I would guess that a 10K resistor would do it. That's what I use with my ATmegas and ATminis. But check your MCU datasheet for appropriate values.

It's quite a common mistake to think that the base-emitter junction already has some sort of current limiting property, but it doesn't. It has very low impedance. I usually think of it as a plain wire. That helps me avoid these kinds of mistakes. Same applies to collector-emitter junction.

By the way, your collector-emitter path has no current limiting resistor or load. Watch out!&nbsp;