2
\$\begingroup\$

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?

switch staus circuit

\$\endgroup\$
5
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Sep 13, 2013 at 18:32
  • \$\begingroup\$ 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? \$\endgroup\$
    – dosas
    Commented Sep 13, 2013 at 18:43
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Sep 13, 2013 at 18:43
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Sep 13, 2013 at 18:47
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Sep 13, 2013 at 18:53

2 Answers 2

1
\$\begingroup\$

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

PNP Switch

Simulation:

PNP switch 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:

PMOS LED Switch

\$\endgroup\$
3
  • \$\begingroup\$ Okay where would I put the parallel port input in your design and why is the p-channel MOSFET more efficient? \$\endgroup\$
    – dosas
    Commented Sep 13, 2013 at 20:40
  • \$\begingroup\$ @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. \$\endgroup\$
    – Oli Glaser
    Commented Sep 13, 2013 at 21:14
  • \$\begingroup\$ 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. \$\endgroup\$
    – dosas
    Commented Sep 14, 2013 at 13:29
0
\$\begingroup\$

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

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.