Electronic – LED before input to Micocontroller


I am designing a circuit to provide a logic high (5V) or logic low (0V) to a microcontroller. How can I incorporate an LED into the circuit so that it is on/off when the logic is high/low, while still providing the microcontroller with either 5V or 0V.

Best Answer

Think of it as your digital signal driving two things, the microcontroller and the LED. If this is just for indicator use on your bench, then 5 mA thru any normal LED will be bright enough. If whatever is driving the digital line can source 5 mA then you hook that line to the micro normally, but add a resistor and LED in series to ground. Let's say the LED drops 2 V at 5 mA, which means the resistor would need to drop 3 V at 5 mA. 3V / 5mA = 600Ω

If the digital output can't handle 5 mA, then have it turn on a transistor which turns on the LED. Here is a nice simple circuit that requires the minimum possible current from the digital signal to light the LED given the gain of the transistor: