Electronic – Driving IR led from 3.3V GPIO using 2N2222 transistor

#nodemcuinfraredledtransistors

I am using the following circuit to drive an IR led from a NodeMCU.

schematic

simulate this circuit – Schematic created using CircuitLab

However, im seeing the following on my scope. (Please ignore the LED model on my schematic)enter image description here

I don't seem to be able to pull the output low quickly enough.Is my schematic right? What am I doing wrong?

Thanks in advance

Best Answer

What am I doing wrong?

In plain language, you mixed up the positions of the transistor and the LED.

To use an NPN transistor for this, you should wire it as a Low Side Switch. That means that the Emitter should go to ground, and the Collector should go to the cathode of the LED. The LED anode then connects to the current limit resistor.

Stack the LED "on top of" the transistor, not the transistor on top of the LED as you've done.

Also be careful to drive this from a NodeMCU pin that doesn't need to be high to boot into your desired mode, as the resistor and transistor base may operate like a pull-down resistor.