# switch status indicator with parallel port

I have put together the circuit below. If the switch is closed the LED should turn off and the parallel port should read the change. The status of the port can be read. But every time the circuit is closed the LED lights brighter. Why does it do this and how do I have to adjust the circuit?

• No series resistor for LED - its connected straight across the 5V (ouch!) through the transistor. The 10k and 47k form a potential divider keeping the transistor ON when the switch is closed. Commented Sep 13, 2013 at 18:32
• Okay there is a resistor for the LED of course i forgot to draw it. So you guys say replace the pull down resistor with a short line? Commented Sep 13, 2013 at 18:43
• The potential divider may be an issue, but it doesn't explain the LED getting brighter when the switch is closed. Current being sourced from the input pin (if it even is one) might be a more likely explanation. Finite transistor gain may mean that the current is limited when the base resistor is so large. Commented Sep 13, 2013 at 18:43
• @ChrisStratton The closing switch directly connects pin15 to the base of the transistor. If this is a current sourcing pin its increasing the base current - hence brighter LED. Commented Sep 13, 2013 at 18:47
• @dosas no, try putting the switch where the pulldown resistor is though, and shrink the 47K resistor until you get a reliable (inverted) reading from the parallel port, and then some more for noise immunity. Use a series resistor with the LED to control its current/brightness. Commented Sep 13, 2013 at 18:53

If I understand correctly something like this should work for you:

Simulation:

The top trace 1V signal represents the switching of the switch from open to closed. The bottom trace shows the current through the LED. You can see the LED current drops to zero when the switch is closed.

Alternatively there is a more efficient logic level P-channel MOSFET version which you might consider:

• Okay where would I put the parallel port input in your design and why is the p-channel MOSFET more efficient? Commented Sep 13, 2013 at 20:40
• @dosas - I added a port symbol in the bottom schematic (TO_PP) for the parallel port connection (same in the PNP case). The MOSFET version is more efficient as it does not continually draw current to keep the LED on, whereas the PNP has current flowing from +5V to base-emitter junction and then through R2. It's only a few hundred uA in the PNP case, so not a big deal either way unless you are very power conscious. Commented Sep 13, 2013 at 21:14
• As Andy and Chris pointed out the input pin is pulled to 5V and I measured the pull up resistor to have 5k. So I replaced R4 in the pnp setup with 500 Ohms. The LED works fine but the input pin is always high. Commented Sep 14, 2013 at 13:29

If you have wired the components correctly there is a feasible way the LED gets brighter when you close the switch......

The parallel port has pull-ups that you have neglected to mention