Building a shed alarm using only NAND gates and a transistor driver
A Class 10 group is building a bicycle-shed alarm on a breadboard. The parts are a 7400 quad NAND IC, two normally-closed reed switches (one on the door, one on the window), a single-pole toggle switch labelled ARM, a 5 V active buzzer that draws 30 mA, and a 5 V regulated supply measured at 4.85 V. The reed switches are wired so a closed switch gives logic 0 and an open switch gives logic 1. The buzzer sounds on logic 1. The teacher's specification is: the buzzer must sound only when ARM is on (logic 1) and at least one reed switch is open. The group has no OR gate and must use only the 7400. On first power-up the buzzer sounds continuously while ARM is off, and one gate of the 7400 becomes noticeably hot. The group has a multimeter but no logic probe. A spare 2N2222 transistor, a 1 kohm base resistor, and a 1N4007 diode are available.
1. Write the Boolean expression for the buzzer and show a NAND-only implementation that fits in one 7400 package. Include a brief truth-table check for the ARM-off and ARM-on cases.
Read the worked answer
Let D = 1 when the door reed is open, W = 1 when the window reed is open, and A = 1 when armed. The buzzer B must be 1 only when A = 1 and at least one sensor is open, so B = A AND (D OR W). Expand to B = (A AND D) OR (A AND W). Using NAND identities, B = NAND[ NAND(A,D), NAND(A,W) ]. Gate 1: NAND(A,D) = (A AND D)'. Gate 2: NAND(A,W) = (A AND W)'. Gate 3: NAND of those two outputs gives (A AND D) OR (A AND W), which is B. Three of the four gates in a 7400 are used. Check: with A = 0, both first-stage NANDs are 1, so the final NAND output is 0 and the buzzer is off. With A = 1, D = 0, W = 0, both first-stage outputs are 1 and B = 0. With A = 1 and D = 1, gate 1 goes 0, so B = 1. The same happens for W = 1. This fits the specification.
2. The buzzer sounds continuously while ARM is off. Using the multimeter, explain how to locate the fault and why the final NAND output must be measured.
Read the worked answer
With ARM off, the specification requires B = 0, so the final gate output should be near 0 V. Measure the final gate output first: if it is near 0 V, the logic is correct and the buzzer is connected to the wrong node or is miswired to the supply. If it is near 4.8 V, either the ARM switch is not giving logic 0 or the gate is faulty. A common wiring error is taking the buzzer from an intermediate gate. With A = 0, both first-stage NAND outputs are 1, so a buzzer connected there will sound continuously. Measure the two first-stage outputs and the final output with the multimeter: expected values with A = 0 are 1, 1, and 0. Move the buzzer to the final output. Also confirm the ARM switch pulls the input firmly to 0 V and 4.85 V, not floating, because a floating TTL input behaves as logic 1.
3. Explain why the 7400 gate becomes hot when it drives the 30 mA buzzer directly, and design a safe driver using the 2N2222. Include the base-resistor calculation and the purpose of the 1N4007.
Read the worked answer
A standard 7400 output can sink about 16 mA and source only about 0.4 mA. The buzzer needs 30 mA, so direct connection exceeds the output rating, causes a large voltage drop, and heats the gate. Use the NAND output to drive the 2N2222 as a low-side switch. Connect the emitter to ground, the collector to the buzzer negative terminal, and the buzzer positive terminal to +5 V. The NAND output feeds the base through 1 kohm. Base current is approximately (4.85 - 0.7) / 1000 = 4.15 mA. With a minimum hFE of about 100, the transistor can sink over 400 mA, far more than the 30 mA needed, so it is in saturation. Connect the 1N4007 across the buzzer with its cathode to +5 V to clamp the inductive kick when the buzzer switches off. This protects the transistor and reduces electrical noise.