Rocket builds an alarm for the treehouse door. It beeps all day long! Rocket laughs. "Oops. Back to the drawing board."
"When should it beep?" Raven asks. Rocket thinks. "Only at night, when the door is open."
Nova projects a small picture of a gate. "A gate takes inputs and gives one output," she says. Let's help fix the alarm.
A LOGIC GATE is a tiny machine that takes Boolean inputs and gives one output. Read each circuit:
INPUT A ββ
ANDβββ OUTPUT
INPUT B ββ | A | B | OUTPUT |
|---|---|---|
| T | T | ? |
| T | F | ? |
| F | F | ? |
INPUT A ββ NOT ββ OUTPUT
| A | OUTPUT |
|---|---|
| T | ? |
| F | ? |
Read carefully:
alarm = (door is OPEN) AND (it is NIGHT)
| door | night? | alarm? |
|---|---|---|
| closed | yes | ? |
| open | yes | ? |
| open | no | ? |
| closed | no | ? |
Now write your own rule for: 'I get a snack'.
Computers use tiny logic gates. Each gate takes TRUE or FALSE inputs and gives one output.
| A | B | OR gate output |
|---|---|---|
| T | T | ? |
| T | F | ? |
| F | T | ? |
| F | F | ? |
| door | night? | alarm = door OPEN AND NIGHT |
|---|---|---|
| open | yes | ? |
| open | no | ? |
| closed | yes | ? |
| closed | no | ? |