resistor for led

Need to look at it like this. In the top example, an NPN transistor is needed to keep 12V away from the Arduino pin.