# Gate Output as a Switch?

I was randomly browsing around some Introduction to circuits websites when I came along this:

The text that went with it is:

Now let us consider what happens when using the output of a chip, such as the 74HC04, to operate an external device. For example, the circuit on the right drives an LED. When the gate is HIGH, then there is no path to GND for cathode of the LED L1. When the gate is LOW, then output pin 2 is connected to ground, and current flows. Since R3 only allows 15mA of current to pass, the gate is safe from being overloaded. Remember that most gates can handle 20mA of current. The same holds true for most microcontrollers.

Can someone explain how this works (I realize this is probably super newbish to most people) I understand how logic gates work, that is an OR gate correct? My "assumption" is that since it's an OR gate....when the Input (or 1) is set to low (or zero) it allows current to pass through?....but if thats the case shouldn't it be like....facing the other way. I guess im confused at why the LED is on the output side with Vcc. I guess I just don't understand why the OR gate isn't facing the other way. Im probably being dumb lol

• Instead of assuming (incorrectly) what kind of gate the 74HC04 is, look it up!! This should have been obvious. If you actually did understand logic gates, you would have known this can't be a OR gate since it has only one input. – Olin Lathrop Sep 29 '11 at 17:14
• @Olin it's just a degenerate case of an OR gate ;-) – vicatcu Sep 29 '11 at 17:41
• Wow, I just now realized i MEANT not gate, for some reasons I got the shapes confused. Derp.... – user3073 Sep 29 '11 at 17:56
• @Vicatcu: No, it's not. I you hold your head just right and squint you can maybe see a inverter as a degenerate NAND or NOR, but definitely not OR. A OR gate doesn't do inversion. – Olin Lathrop Sep 29 '11 at 22:40
• @Olin yes of course you are right, I was merely being facetious... – vicatcu Sep 29 '11 at 23:20

To expand a bit on @Barsmonster's answer, if you look at the CMOS implementation of a gate, there is a "pull-up" network of P-type transistors and a "pull-down" network of N-type transistors. The inverter is the simplest case of such a gate and it looks something like this:

When A (labeled "1" in your diagram) is set to Vss (GND), the P-type transistor turns on (and the N-type transistor turns off), and Q (labeled "2" in your diagram) is effectively connected to Vdd. When A is set to Vdd the N-type transistor turns on (and the P-type transistor turns off), and Q is effectively connected to Vss.

The current limit they are talking about is how much the N-type transistor can sink without burning up.

It's not an OR gate, that would have at least 2 inputs. The output would be active (read: high) if input A OR input B (or both) would be active. The 74HC04 is an inverter, it makes the output high if the input is low and vice versa.

So the output is either low (0V) or high (+5V). If it's high then there's no voltage difference between the output and $V_{CC}$, so there's no current. Remember Ohm's Law:

$I = \dfrac{V}{R}$

If the output is low there is a voltage difference and current can flow from the higher voltage $V_{CC}$ (+5V) to the lower voltage of the gate's output (0V).
The drive capability of a gate is sufficient to light a LED, for more power-hungry devices as a relay you'll need to add a transistor to provide the required current.

This is invertor, not OR gate.

Majority of gates does not pass current. They ether connect output to VCC or connect output to GND, that's it. The difference between them is when they connect output to VCC/GND.

For this invertor gate, it connect output to VCC when input is LOW, and to GND when input is high.

• Ok.....I guess im confused then why Ground is connected as Input? I mean output is the Pointed edge of the NOT gate....so wouldn't it always be open? (since ground is 0v......so it's low...so it'll always be open). Obviously if you can't tell im a beginner at electronics. – user3073 Sep 29 '11 at 18:07
• @Sauron, this gate always have connections to VCC & GND, it's just almost never drawn on the schematics. – BarsMonster Sep 29 '11 at 19:23
• I understand, but why is the Input point towards the Ground? shouldn't the input be from Vcc? – user3073 Sep 29 '11 at 19:27
• @Sauron, in order to drive the output to GND (and thus turn on the LED), an input of Vcc must be provided. Don't think of it as current flowing "out" of the gate, but rather, the gate is providing a path to GND. – vicatcu Sep 29 '11 at 23:22
• Ah ok that makes more sense then. Wouldn't the input always be open though if it's connected to ground (since ground is 0v?) – user3073 Sep 29 '11 at 23:38