NPN (Not Pin In)

The 2n2222a is a switch.   0V to base has the transistor off.  When you push the button it energizes the transistor allowing the circuit to complete to the emitter, which is connected to ground.   

So the direct connect LED math works out to be.
(5V-1.5V)/20mA = 175 ohm resistor. Usually you use a 220 ohm resistor to dissipate the 3.5V.
using the 1k ohm resistor you get: (5V-1.5Vled)/1k ohm = 3.5mA. 3.5mA /20mA is a 17.5% duty cycle. It is like running PWM on Arduino.

The LED connected to the 2N2222A connects to the 5V