I have a project using an ESP8266 to control a lamp socket. In very simple terms the sketch switches the lamp socket on or off based on some conditions. The sketch works fine.
What I would like to be able to do is put into the lamp socket either a 3 V 120 mA incandescent bulb or a 3 V 1 mA LED bulb.
The ESP8266 can easily drive the LED directly but of course can't drive the incandescent bulb, so I added a 2N4401 transistor into the circuit with the ESP8266 controlling the base of the transistor.
The problem is that the base resistors required vary dramatically. My calculations indicate the incandescent requires 383 Ω while the LED requires 4.66K Ω. In practical testing, the incandescent requires 1 kΩ to completely shut it off (much less than that and the incandescent will slightly glow when the pin connected to the base is low--i.e., off) yet fully saturate the transistor--i.e., fully on.
Strangely, the LED will not shut off fully even with a 20 kΩ resistor while at this level of resistance on the base the incandescent barely lights.
Using a standard BJT NPN transistor is not going to do the trick. I was thinking maybe a Darlington transistor or MOSFET might be a better solution, but I have never worked with either (although I have done a bit of reading on both.)