Skip to content

Digital Logic

Build a latching alarm with a voter and a NOR latch

A good alarm panel does three things: it ignores a single false reading, it trips when the evidence is real, and it stays tripped after the sensors clear, until someone presses RESET. With logic gates that's two blocks: a 2-of-3 majority voter to decide, and an SR latch made of two NOR gates to remember.

The spec

  • Three sensors, S1, S2 and S3; one alone must not trip it
  • Any two trip the alarm
  • Once tripped, the alarm stays on after the sensors clear
  • RESET clears it

Block 1: the vote

Three ANDs, one per pair of sensors, then two ORs:

SET = (S1 AND S2) OR (S2 AND S3) OR (S1 AND S3)

One faulty sensor, stuck on, can never make SET 1 alone.

Block 2: the NOR latch

Two NOR gates in a loop. The first takes SET and the second gate's output; the second takes RESET and the first gate's output. The second gate's output is Q, the alarm.

  • SET goes to 1: the first NOR outputs 0, so the second, with RESET at 0, outputs 1. ALARM on.
  • SET drops back to 0: the first NOR now sees Q = 1 and stays at 0, so Q stays 1. The loop holds itself.
  • RESET goes to 1: Q is forced to 0, and stays there when RESET is released.

Live experiment

Trip the alarm, then clear it

Three sensors feed a majority voter, the vote sets a NOR latch, and the latch's Q is the alarm. Press RESET to wake it, then try one sensor (ignored), two (it trips), clear both (it stays on) and RESET (it stops). Tick off all four checks.

Try it yourself: free lesson

“Project: Alarm panel” is the project that ends Nand Narrows, Digital Logic World 2. Free with an account. Lessons unlock in order, so you’ll do the 13 before it first.

Parts list

GateHow manyJob
AND3One per pair of sensors
OR2Combine the pairs into SET
NOR2The latch: SET side and RESET side

Test it in this order

  1. Press and release RESET: ALARM off. (At power-up the latch could hold either state.)
  2. One sensor on: still off. A second: on.
  3. Clear both sensors: still on.
  4. RESET: off. A different pair of sensors: on again.

Going further

Add an ARM switch by ANDing it with SET, so the panel ignores the sensors while disarmed. Drive a buzzer from Q through a transistor, since a gate output can't supply a loud buzzer's current. In a microcontroller the same design is a few lines: count the sensors that read 1, and if two or more, set a bool that only the reset button clears.

Free lesson

Now build it yourself

Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.

Try it yourself: free lesson

“Project: Alarm panel” is the project that ends Nand Narrows, Digital Logic World 2. Free with an account. Lessons unlock in order, so you’ll do the 13 before it first.

Or start from the very first lesson, no account needed

Practice questions

Three quick questions from the lessons. Pick an answer to check it.

  1. Question 1 of 3One sensor reads 1, the others 0. The alarm…
    Show the answer

    Answer: Stays off: one of three isn't a majority. The vote needs two. A single faulty sensor can't trip the panel.

    • Why not “Resets”? Only the RESET input clears the latch. A single sensor doesn't touch it.
    • Why not “Flickers”? The voter's output is a steady 0 with one sensor on, so nothing changes.
    • Why not “Trips”? One sensor alone is a minority. The voter needs two before it sets the latch.
  2. Question 2 of 3Both sensors clear after the trip. The alarm…
    Show the answer

    Answer: Stays on: the latch holds until RESET. SET dropped back to 0, but the NOR loop keeps Q at 1. Only RESET clears it.

    • Why not “Turns off”? That's what a plain voter would do. The latch remembers the trip until RESET.
    • Why not “Trips again”? It never stopped. With the sensors clear, SET is 0 and the latch simply holds.
    • Why not “Goes X”? The latch is in a known state after the trip: Q is 1 and holds.
  3. Question 3 of 3LIGHT = (DARK AND MOTION) OR OVERRIDE. Daylight, no motion, override on. Is the light on?
    Show the answer

    Answer: Yes: the override wins on its own. The bracket is 0 AND 0, which is 0. Then 0 OR OVERRIDE is 0 OR 1, which is 1. The override is one side of an OR, so it's enough by itself.

    • Why not “No: there's no motion”? Motion only matters inside the AND. With the override at 1, the OR's output is 1 whatever the AND says.
    • Why not “Only at night”? Night only matters to the AND. With the override on, the OR gives 1 by day or night.
    • Why not “No: it isn't dark”? Darkness only matters inside the AND. The override reaches the OR directly, so the light comes on anyway.
Keep practising: free lesson

“Project: Alarm panel” is the project that ends Nand Narrows, Digital Logic World 2. Free with an account. Lessons unlock in order, so you’ll do the 13 before it first.

Questions people ask

Why does an alarm need a latch?

A sensor might only see smoke, or an open door, for a moment. Without memory the alarm would stop the instant the sensor cleared. A latch holds the alarm on until a person deliberately resets it, so a short event can't go unnoticed.

What happens if RESET is held while two sensors are tripped?

With SET and RESET both 1, both NOR gates output 0, so the alarm is off only while RESET is held. Let go of RESET while the sensors still read 1 and the latch sets again at once.

Why is the alarm unknown when the circuit first powers up?

A latch is two gates holding each other in place, and at power-up either state is possible. A real panel pulses RESET automatically at power-on, often with a resistor and capacitor, so it always starts quiet.

Every topic