How can a logic 0 change a logic 1 to logic 0 given these circumstances? This is a 4x3 numeric keypad. An output RB3, RB4, or RB5 may be connected to an input RB9, RB8, RB7, or RB6 by a pushbutton. The inputs have internal weak pull-ups. When the pushbutton in yellow square is pressed, RB3 and RB7 connect, rendering RB7 logic 0.

If a logic 1 voltage supply is provided by the input pins, how can a logic 0 of the output pins render the input pins a logic 0 if the output pins do not have open-drains enabled? A logic 0 is an absence of or a smaller voltage than that of logic 1. Shouldn't this be reversed in that the logic 1 voltage on the output pins render the input pins logic 1 as well when the pushbutton is pressed?

I don't know why I am having difficulty understanding this. Unless my understanding of voltage is skewed, I see know way to reverse the order of my way.

• @ABCDEF I don't know what you did, but the image include code that you had in your question was not what the image include button or the help page would have done... Aug 12 '17 at 21:13
• It seemed to be acceptable based from the example provided in the "Images" button. I guess reading the text below it would have helped, tho! Aug 12 '17 at 21:16
• "how can a logic 0 of the output pins... Shouldn't this be reversed in that the logic 1 voltage on the output pins render the input pins logic 1" - make up your mind, is the output pin logic 0 or logic 1? "if the output pins do not have open-drains enabled?" - who says they aren't open-drain? Aug 12 '17 at 21:19
• Aww, come on, you could have chosen a colour with more contrast against white than that. Aug 12 '17 at 21:19
• Bruce Abbott, the example code does not show the enabling of open-drains for the output. For example: #define CONFIG_R0_DIG_OUTPUT() CONFIG_RB5_AS_DIG_OUTPUT() and a method which calls CONFIG_R0_DIG_OUTPUT().. What I'm saying is that /I/ think it should be reversed so that outputs give a logic 1, not the other way which is the way the book uses. In the book, the output pins are logic 0. Aug 12 '17 at 21:23

The question is not clear. It sounds like you are asking why/how the logic 0 output on RB3 can force the RB7 input to a logic 0 even though it has a weak pull up to a logic 1. The answer is that it is a very weak (large value resistor) pullup intentionally, so that it can be overridden without damage.

Also, a logic 0 is not and "absence" of voltage. A logic 0 is a voltage within a specifically defined range of values, often 0.0 V to 0.8 V. An absence of voltage is a floating pin. If it is an input pin, the weak pullup with turn an absence of voltage into a logic 1.

• I'm sorry. I thought 0.0 V meant no voltage at all, which usually falls within a range of voltages causing a flow of electrons declared as logic 0. I'm trying to imagine how a 1 can be overridden even with a large value resistor there. A resistor reduces the voltage across all lines in a parallel circuit. Because it is logic 1, a 5V source may turn to 3V which still falls within the logic 1 range. Now introduce a smaller voltage. How can 3V turn to .5V? Logic 1 and 0 are based on voltage, right? My brain really isn't designed to understand electricity. Electrons are weird Aug 12 '17 at 22:05
• Ignore the electrons. Think Kirchoff's laws. Resistors do not "reduce voltage", they provide partial conduction of current. Effectively you end up as a voltage divider where the wires and switch are a very small resistor and the pullup is very large. Aug 12 '17 at 22:23

I think your comment to AnalogKid's answer explains where you are confused.

I'm sorry. I thought 0.0 V meant no voltage at all, ...

It does. But there's a difference between 0 V in the case where nothing is connected and 0 V in the case where a switch or transistor is connecting that point to circuit ground. The first can't supply any current. The second can. The second is what pulls your weak pull-up to ground.

In your original question you stated, "A logic 0 is an absence of or a smaller voltage than that of logic 1." It's the latter - a smaller voltage but with a good drive capability. simulate this circuit – Schematic created using CircuitLab

Figure 1. (a) It is obvious that a mechanical push-button will beat the pull-up resistor and the input will be pulled to 0 V. (b) It's a little less obvious in the case of a transistor switch but the same logic holds true. In this case the saturation voltage of the transistor when turned fully on will pull down to about 0.2 V.

... which usually falls within a range of voltages causing a flow of electrons declared as logic 0.

Flow of electrons isn't a helpful way of thinking about this. Just think of voltages and currents flowing from positive to negative. This convention was established before the discovery of the electron by J. J. Thompson but it still works for us.

I'm trying to imagine how a 1 can be overridden even with a large value resistor there.

The resistor will be the top half of a voltage divider. It's resistance might be, say 100 kΩ whereas the pull-down by the multiplexing transistor might be 100 Ω. Which will win? The lower value resistor and the resultant voltage at the multiplexor input will be $\frac {100k}{100} = 0.1\%$ of supply. This will definitely read as a logic 0.

A resistor reduces the voltage across all lines in a parallel circuit. Because it is logic 1, a 5V source may turn to 3V which still falls within the logic 1 range.

This is a bit garbled but I think I've explained it above.

Now introduce a smaller voltage. How can 3V turn to .5V? Logic 1 and 0 are based on voltage, right?

This is based on the faulty logic of the previous quote so it is not true. Again, it's who wins: pull-up or pull-down.

My brain really isn't designed to understand electricity. Electrons are weird.

Hopefully this will help.

• Yes, I'm sorry, I get the mathematical reason of why this works. I'm just trying to "visualize" what is actually happening on the electron level. And in doing so I lose touch with the mathematics. Yes, it's a battle of fractions to see if the numerator is smaller than the denominator, and in this case the value of Q1 would have to be very small relative to R2 to get a voltage value that falls within the logic 0 range. If I cannot intuitively visualize what is actually happening, I find myself worse off despite understanding the mathematics. Do you have this problem, too? Aug 15 '17 at 0:08
• I also tend to visualise. I hope my answer helped. Build the transistor circuit and try it out with various base resistor values while measuring the collector voltage. It will help you in several ways. Aug 15 '17 at 5:53