Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to read OUTPUT 1 and OUTPUT 2 to digital pins with pull-down resistors on a micro controller but they will always read HIGH. How would you detect the change in current so that when SW1 is closed a digital HIGH or LOW could be read on OUTPUT 1?

push buttons

share|improve this question

You should determine what voltage is on your outputs in either state and compare it with input voltage levels given in datasheet on your MCU. I suppose it is about 4 V at pressed state which is HIGH for 5 V TTL and CMOS circuits.

You have use amplifier for these signals. There are some choices.

  1. Comparator. It need to have rail-to-rail inputs or higher supply voltages

  2. PNP transistor (if voltage drop on R1 and R2 exceed Vbe ~ 600 mV) or P-MOS transitor with low enough threshold voltage.

share|improve this answer

You have 5V driving through R1 then D1 then R3 and D3 in one particular configuration of switches (SW1). If the LEDs drop 1.8 volt each this means 3.6 volts in total with R1 and R3 mopping up the remaining 1.4 volts (3.6 + 1.4 = 5).

Assuming you have 20 mA flowing through the LEDs (pretty standard sort of stuff), each resistor will be about 35 ohms.

This means that when SW1/SW3 is inactivated, OUTPUT1 will be at 5 volts. When either SW1 or SW3 are activated, 20 mA flows through R1 and OUTPUT1 = ~ 4.3 volts. This is your problem - you are not getting a decent low-logic level.

To remedy this you could consider using a comparator or a PNP transistor (this will also invert your logic level).

share|improve this answer

Here is how you would hookup the PNP transistor to drive OUTPUT1. A connection for OUTPUT2 would be similar. The PNP base resistor could be 2.2K to 4.7K ohms. The pull-down on the PNP collector could be 1K to 4.7K. This should work as long as the drop of the LED's D1 and D3 are a total of about 3.5V or less. If you have LEDs that have a forward drop of more than this such as some Green or Blue LEDs then this added PNP idea will not work unless the voltage supply was higher.

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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