Lesson 42: Logic gates
이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
English
Gates you can press
- A logic gate takes inputs that are 1 or 0 and gives one output.
- Here the inputs are two buttons: pressed is 1, not pressed is 0. Each LED is the output of one gate.
- Press the buttons on the board and fill in the truth tables yourself.
Words for this lesson
| Word | Meaning |
|---|---|
| AND | 1 only if both inputs are 1 |
| OR | 1 if at least one input is 1 |
| NOT | the opposite of the input |
| NAND / NOR | NOT AND / NOT OR |
| XOR | 1 if the inputs are different |
English
Truth tables
| A | B | AND | OR | XOR |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
- NAND is the opposite of AND: 1, 1, 1, 0. NOR is the opposite of OR: 1, 0, 0, 0.
English
Gates in C++
| Gate | C++ |
|---|---|
| A AND B | A && B |
| A OR B | A || B |
| NOT A | !A |
| A NAND B | !(A && B) |
| A XOR B | A != B |
English
In the exam
- 0478/22/M/J/25 Q8(a): draw the XOR symbol and complete its truth table: 0, 1, 1, 0, the same as your XOR LED.
- 0478/12/F/M/22 Q3(a): tick the gates that give 1. A = 1, B = 1: AND and OR. A = 0, B = 0: NAND and NOR. A = 1, B = 0: OR, NAND and XOR. Press the buttons to check each row.
난이도 3/5 · 200코인 + 오늘 첫 완료 시 작은 보너스 추가
Button A is on pin 2 and button B on pin 3 (pressed reads LOW, so A is true while A is pressed). Make the three LEDs into logic gates: pin 11 shows A AND B, pin 12 shows A OR B, and pin 13 shows NOT A. Check presses no button, then A, then B, then both.
출력을 보려면 '실행'을 클릭하세요.
난이도 4/5 · 280코인 + 오늘 첫 완료 시 작은 보너스 추가
Now three more gates: pin 11 shows A NAND B (NOT (A AND B)), pin 12 shows A NOR B (NOT (A OR B)), and pin 13 shows A XOR B: on when exactly one button is pressed, not both.
출력을 보려면 '실행'을 클릭하세요.