how to calculate resistor to a base of a 2n2222?

To limit the current, you need a resistor in series with the LED

This is ok for small leds of about 20 mA
Your big 1W (400 mA) led needs a current source of about 300 to 450 mA, which is something different than a 5V voltage source.