Module 4 · Yes, No, And, Or

What’s the difference between two switches in a row and two side by side?

Lesson 4.1 · Two Switches, One Light

Jenny · Sarah

Same switches. Rewired. Different rule.

Jenny hands Sarah the board.

Two switches, one bulb, labeled A and B. Sarah flips A. Nothing. She flips B. The bulb lights.

She flips A off again and it goes dark. Jenny rewires it while nobody’s looking and now either switch lights it.

Same parts, different wiring, different rule.

The short answer

In a row is AND: both switches on, or no light. Side by side is OR: either switch lights it. Same parts, different wiring, and the wiring is the rule. That’s the first step from a flashlight toward a processor.

Try it yourself

Flip A and B every way you can and watch the light.

Switches wired one after the other. When does the light come on?

AND
Light off

AND

On only when both switches are on.

What you just did has a name

A logic gate

A logic gate is a tiny circuit that takes one or two on/off inputs and gives an on/off output by a fixed rule.

An AND gate is on only when both inputs are on. An OR gate is on when either input is on.

In a chip, each gate is a handful of transistors, and there are billions of them.

A few more things

On means true

Engineers say on is 1, or true, and off is 0, or false. So an AND gate answers “are both of these true?” and an OR gate answers “is at least one true?”

Made of transistors

Jenny’s board uses switches you flip by hand. In a chip, the switches are transistors flipped by electricity from other gates. Same rules, no fingers.

You use them every day

A car’s dome light comes on if the driver’s door OR the passenger’s door is open. A microwave runs only if the door is shut AND you pressed start.

Go deeper

The longer version, if you want it.

The truth table

Engineers describe a gate with a little chart called a truth table: every possible combination of inputs, and the output for each. Two inputs means four rows: off-off, off-on, on-off, on-on.

For AND, only the last row is on. For OR, every row but the first is on. That’s the whole definition. No matter how complicated a chip gets, it’s built from gates whose truth tables fit on a sticky note.

Quick check

A safe opens only if you turn both keys. Which gate is that?

Let’s take it slower

Picture a hallway with two doors in a row. To get through, both doors have to be open. That’s AND. Now picture a room with two doors side by side. To get in, either one being open is enough. That’s OR. Electricity flowing through switches works the same way as you walking through doors.

More examples

1

The two-person rule

Some bank vaults need two employees, each with their own key, at the same time. That’s an AND gate made of people.

2

The doorbell

Some houses have a button at the front door and one at the back, both wired to the same chime. Press either one and it rings. That’s OR.

Back to the question

So what’s the difference between in a row and side by side?

Show the answer

In a row is AND: both switches on, or no light. Side by side is OR: either switch lights it. Same parts, different wiring, and the wiring is the rule. That’s the first step from a flashlight toward a processor.

One last question

Mark asks what a logic gate actually is. Who got it right?

Talk Card

Talk Card · 4.1

A logic gate turns on/off inputs into an on/off output by a rule. AND needs both inputs on; OR needs at least one.

How Computers Work · pettigrewlab.com/learn

Next lesson