PWM and NPN tolerance

I'm trying to control a bank of lights with an external 12V battery. My plan was to use PWM and an NPN in a basic setup such as this: http://yfrog.com/jmledschematicp. I've put this circuit together but I don't quite understand how transistors behave when one uses PWM at the base of the NPN. if I do this: analogWrite(NPNbase, 128), does the transistor act as if it has 2.5V applied to its base or as if it's being switched on and off rapidly? The reason I'm asking is because I'm concerned about exceeding the max power dissipation of the transistor. When I read the voltage accross the collector and emitter, I get a high voltage as if 2.5V is being applied, not 5V.

The transistor acts as if it's being switched on and off rapidly (because it is!)

If you are measuring the voltage across the collector and emitter with a DMM you're getting an average voltage because the DMM is not fast enough to keep up with the changes in voltage.

I wouldn't be too concerned about power dissipation of the transistor in your case, the current just isn't high enough (<10mA).

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons

That's what I was hoping to hear! The lights I'll be using will draw around 150 mA (much closer to the max draw of 200mA for the 2N3904 I plan on using http://www.fairchildsemi.com/ds/2N/2N3904.pdf) is that still acceptable?

Ah, well then you'll need some different resistors! (470 ohm will be too much).

Instead of a 2N3904 consider a 2N2222 as it's rated for 600mA.

Even better consider using a MOSFET and power dissipation will be much lower (though you should still be pretty safe at 200mA -- it will get somewhat warm I'm predicting):

http://ruggedcircuits.com/html/circuit__7.html

--
The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected

Right, good call! Thanks so much for the advice and clarifying the PWM thing.