Skip to content

Punjab Board Class 10 Physics · Chapter 19: Electronics

Logic gates and their uses

Section 19.4Section 19.5

A logic gate turns 1s and 0s at its inputs into a single 1 or 0 output. AND gives 1 only if both inputs are 1; OR gives 0 only if both are 0; NOT inverts. NAND and NOR are AND and OR followed by NOT. A NAND gate can run a burglar alarm, and an OR gate a smoke-or-heat fire alarm.

Loading simulation…

Symbols match your course. Open the full circuit builder simulation for more presets and teacher tools.

What is a logic gate?

A logic gate is a small digital circuit that takes one or more inputs, each high (1) or low (0), and produces a single output that is also 1 or 0. Which output appears depends only on the combination of inputs and on the type of gate. Most gates have two inputs and one output; the NOT gate is the exception, with one input and one output.

Gates are the decision-makers inside smartphones, computers, calculators and digital watches. Millions of them, joined together, process the binary data that these devices store.

The five gates in this chapter

In the equations below, A and B are the inputs and X is the output.

  • AND gate: X=A⋅BX = A \cdot B. The output is 1 only if A and B are both 1. Symbol: a shape with a flat back and a rounded, D-shaped front.
  • OR gate: X=A+BX = A + B. The output is 0 only if A and B are both 0; any 1 at the input gives 1. Symbol: a curved back and a pointed front, like a shield.
  • NOT gate (inverter): X=A‾X = \overline{A}. One input, and the output is always the opposite. Symbol: a triangle with a small circle (bubble) at its tip.
  • NAND gate (NOT AND): X=A⋅B‾X = \overline{A \cdot B}. An AND gate followed by a NOT gate. The output is 0 only when both inputs are 1. Symbol: the AND shape with a bubble on the output.
  • NOR gate (NOT OR): X=A+B‾X = \overline{A + B}. An OR gate followed by a NOT gate. The output is 1 only when both inputs are 0. Symbol: the OR shape with a bubble on the output.

The bubble always means "invert here". The bar drawn over an expression means NOT of everything under it.

All the truth tables together

ABANDORNANDNOR
000011
010110
100110
111100

For the NOT gate: input 0 gives output 1, and input 1 gives output 0.

Notice that the NAND column is the AND column with every value flipped, and the NOR column is the OR column flipped. That is a quick way to check a table in an exam.

Worked example 1: reading a gate

A NAND gate has A = 1 and B = 0. What is its output?

First find AND: 1⋅0=01 \cdot 0 = 0. Then invert it: NOT 0 = 1. A NAND output is 0 only for the single row where both inputs are 1.

Worked example 2: a NOR gate followed by a NOT gate

Show that a NOR gate whose output feeds a NOT gate behaves as an OR gate.

ABNOR outputafter NOT
0010
0101
1001
1101

The final column matches OR exactly. Inverting twice cancels out, leaving the OR that was inside the NOR.

Worked example 3: two NOT gates into a NOR gate

Each input passes through its own NOT gate before reaching a NOR gate. Show the result is AND.

  • A = 0, B = 0: the NOR gate receives 1 and 1, so it gives 0.
  • A = 0, B = 1: it receives 1 and 0, so it gives 0.
  • A = 1, B = 0: it receives 0 and 1, so it gives 0.
  • A = 1, B = 1: it receives 0 and 0, the only case where NOR gives 1.

The output is 1 only when both A and B are 1, which is AND. Going beyond the book: a NOR gate with its two inputs joined together works as a NOT gate, so NOR gates alone can be combined to make every other gate.

Uses of logic gates (section 19.5): a burglar alarm

A single NAND gate can run a simple burglar alarm.

  • Input B comes from an LDR connected to the positive side of the supply (beyond the book: a fixed resistor from B to the negative side completes a potential divider). While light shines on the LDR its resistance is low, so B is high (1). If an intruder blocks the light, the LDR's resistance rises and B falls low (0).
  • Input A comes from a hidden push switch, arranged so that A is normally high (1) and goes low (0) when someone steps on it.
  • The output drives the alarm.
SituationABNAND outputAlarm
All quiet110silent
Light beam blocked101sounds
Mat switch pressed011sounds
Both001sounds

Because a NAND gate stays at 0 only while every input is 1, any single disturbance sets off the alarm.

Uses of logic gates: a fire alarm

A fire alarm should react to smoke or heat. A smoke sensor feeds input A and a heat sensor feeds input B of an OR gate. If either sensor (or both) gives a 1, the output becomes 1 and can switch on a siren and start a sprinkler or extinguisher. Simple alarms can also be made from parts such as thermistors, timer chips and operational amplifiers, but an OR gate captures the logic: smoke OR heat means fire.

Logic gates in the simulation

The circuit builder has no gate chips, but switch circuits and an LDR show the same behaviour.

  1. From Starting circuits, choose Empty. Place two Switch parts in series with a Lamp, select each in turn and tick or untick Switch closed: the lamp follows the AND column.
  2. Rebuild with the switches on separate branches: the lamp now follows the OR column.
  3. Load LDR divider. Select the fixed Resistor and move the Light level slider. Its p.d. is large in bright light and small in the dark, just like input B of the burglar alarm switching from 1 to 0 when the beam is blocked.

Common mistakes

  • Mixing up NAND and NOR. A NAND gate gives 0 just for inputs 1 and 1; a NOR gate gives 1 just for inputs 0 and 0.
  • Forgetting what the bubble means. A small circle on a gate's output inverts it, turning AND into NAND and OR into NOR.
  • Drawing the NOT gate with two inputs. It has one input and one output.
  • Writing the NAND equation as the AND of two inverted inputs. The bar goes over the whole of A·B, so the inversion happens after the AND.
  • Saying the burglar alarm sounds only when both the beam and the switch are disturbed. The NAND output becomes 1 as soon as either input goes to 0.
  • Choosing AND for a fire alarm. Smoke or heat on its own must set it off, so an OR gate is needed.

Exam practice

Exam-style questions

Original questions written in the style of Punjab board exams. Try each one before you reveal the answer.

  1. 1.A student is learning the symbols and truth tables of logic gates.

    1. (a)Describe in words what a NOR gate does, then give its logic equation.

      2 marks
      Show the answer

      Answer: It gives a 1 just for the input pair 0, 0; for every other input combination it is 0. X = (A + B) with a bar over the whole of A + B.

      Marking points

      • Output 1 only when A and B are both 0
      • X = NOT (A + B), bar over A + B
    2. (b)Write the truth table of a NAND gate.

      2 marks
      Show the answer

      Answer: Inputs 00, 01 and 10 each give X = 1; inputs 11 give X = 0.

      Marking points

      • All four rows listed
      • Output 0 only for 1, 1
    3. (c)Why is a NOT gate also called an inverter?

      1 mark
      Show the answer

      Answer: Its output is always the opposite of its input: 1 becomes 0 and 0 becomes 1.

      Marking points

      • Output is the opposite of the input
  2. 2.A burglar alarm uses one NAND gate. Input B comes from an LDR circuit and is high while light falls on the LDR. Input A comes from a push switch and is high until the switch is pressed.

    1. (a)Explain why input B goes low when an intruder blocks the light.

      2 marks
      Show the answer

      Answer: When the beam is cut off, the LDR's resistance shoots up, so most of the supply p.d. is now dropped across the LDR and the voltage reaching input B falls to low (0).

      Marking points

      • LDR resistance rises in the dark
      • Voltage at B falls to 0 (low)
    2. (b)Use the NAND truth table to explain when the alarm sounds.

      3 marks
      Show the answer

      Answer: With nobody there, A = 1 and B = 1 and the NAND output is 0, so the alarm is silent. If the beam is blocked (B = 0), the switch is pressed (A = 0), or both, the output becomes 1 and the alarm sounds.

      Marking points

      • A = 1, B = 1 gives output 0: silent
      • Either input 0 gives output 1
      • Alarm sounds for either or both disturbances
  3. 3.A factory wants a fire alarm that rings when a smoke sensor or a heat sensor detects a fire.

    1. (a)Which single logic gate should be used? Give a reason.

      2 marks
      Show the answer

      Answer: An OR gate, because its output is 1 when either input is 1 (or both), so smoke alone or heat alone sets off the alarm.

      Marking points

      • OR gate
      • Output 1 when either sensor gives 1
    2. (b)Each input of a NOR gate is first passed through a NOT gate. Show that the combination acts as an AND gate.

      3 marks
      Show the answer

      Answer: For A = 1, B = 1 the NOR gate receives 0 and 0, so its output is 1. For any other inputs at least one NOT output is 1, so the NOR output is 0. So a 1 appears for the pair 1, 1 and nowhere else, which is AND.

      Marking points

      • 1, 1 becomes 0, 0 at the NOR inputs, output 1
      • Any other input gives a 1 into the NOR, output 0
      • Conclusion: matches AND

Quiz

Quick check

6 questions

  1. 1.The output of a two-input NOR gate is 1 when:
  2. 2.The output of a NAND gate is 0 when:
  3. 3.Which logic equation describes an OR gate?
  4. 4.On a logic gate symbol, a small circle at the output means the output is:
  5. 5.A NAND gate has inputs A = 0 and B = 1. Its output is:
  6. 6.A fire alarm must ring if smoke OR heat is detected. The gate that fits is:

Related articles

Next step

Now see it move

Open the full circuit builder simulation for every preset, graphs and the teacher tools, then test yourself.

Circuit builder simulation: build any circuit you like