Build it step by step
0 of 7 doneBuild the latch
Gate 1 and gate 2 cross-coupled as in the table.
Add the inputs
Reed switch to +5 V with a pull-down, giving a low when the door opens. Reset button with a pull-up.
Add the outputs
LED on Q and a BC547 driver for the buzzer.
Power up and reset
Press reset so Q starts low.
Open the door
The LED and buzzer start.
Close the door
They stay on, because the latch remembers.
Press reset
They stop. Open the door again to repeat.
How do you build an alarm with latch memory?
An SR latch made from NAND gates remembers that a door was opened until you reset it. You need 74HC00 quad NAND gate, Door reed switch MC-38, Tactile push button 6 mm, Resistor 10 kΩ × 3, LED 5 mm red, Resistor 330 Ω, Active buzzer 5 V, BC547 NPN transistor, Breadboard 830 Tie Points, Jumper wires male to male (40 pcs, 20 cm), Breadboard power supply module (MB102) and 12 V 2 A DC adapter. It takes 7 steps and about 45 minutes.
- Level
- Beginner
- Time
- About 45 min
- Parts
- 12
Parts list
- Integrated CircuitsBuy
- SensorsBuy
- SwitchesBuy
- PassivesBuyResistor 10 kΩ × 3
- SemiconductorsBuyLED 5 mm red × 1
- PassivesBuyResistor 330 Ω × 1
- Motors & ActuatorsBuy
- SemiconductorsBuy
- PrototypingBuy
- PrototypingBuy
- PowerBuy
- PowerBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| 74HC00 pin 14 and pin 7 | +5 V and GND | Power |
| Reed switch | +5 V to node S, with 10 kΩ from node S to GND | High while the door is shut, low when it opens |
| Node S | Pin 1 (gate 1 input A, SET active low) | Set input |
| Reset button | Node R to GND, with 10 kΩ from +5 V to node R | Low when pressed |
| Node R | Pin 4 (gate 2 input A, RESET active low) | Reset input |
| Pin 3 (gate 1 output Q) | Pin 5 (gate 2 input B) | Cross-coupling |
| Pin 6 (gate 2 output) | Pin 2 (gate 1 input B) | Cross-coupling |
| Pin 3 (Q) | 330 Ω then red LED to GND | Shows the alarm is set |
| Pin 3 (Q) | 10 kΩ to BC547 base; buzzer from +5 V to the collector; emitter to GND | Buzzer driver |
| Unused gate inputs (pins 9, 10, 12, 13) | GND | Tie off |
No code needed
No code. Power: a breadboard power supply module (MB102) from the 12 V adapter, with its jumper set to 5 V. A NAND latch has active-low inputs. A low on SET makes Q high, a low on RESET makes Q low, and with both high it keeps its last state. The reed switch is closed when the magnet is next to it, so node S is high with the door shut and falls when the door opens.
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Door shut, after reset | LED and buzzer off |
| Door opened | LED and buzzer on |
| Door closed again | Still on until reset |
| Reset pressed with the door shut | Off |
If it does not work
Starts on at power up
Normal, the latch may power up either way. Press reset.
Never latches
The cross-coupling wires are crossed wrongly. Re-check pins 3, 5, 6 and 2.
Buzzer too quiet
The BC547 base resistor is too large or the buzzer needs 5 V.
Works with the magnet backwards
Fine, the reed only needs the magnet close.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the alarm with latch memory?
74HC00 quad NAND gate, Door reed switch MC-38, Tactile push button 6 mm, Resistor 10 kΩ × 3, LED 5 mm red, Resistor 330 Ω, Active buzzer 5 V, BC547 NPN transistor, Breadboard 830 Tie Points, Jumper wires male to male (40 pcs, 20 cm), Breadboard power supply module (MB102) and 12 V 2 A DC adapter.
How long does the alarm with latch memory take to build?
About 45 minutes for a beginner maker, in 7 steps.
How do I know the alarm with latch memory works?
Door shut, after reset: LED and buzzer off. Door opened: LED and buzzer on. Door closed again: Still on until reset.
Starts on at power up: what should I check?
Normal, the latch may power up either way. Press reset.
Never latches: what should I check?
The cross-coupling wires are crossed wrongly. Re-check pins 3, 5, 6 and 2.
Buzzer too quiet: what should I check?
The BC547 base resistor is too large or the buzzer needs 5 V.
Works with the magnet backwards: what should I check?
Fine, the reed only needs the magnet close.
