Practical case: Dual Input Alarm System using OR Gate

Dual Input Alarm System using OR Gate prototype (Maker Style)

Level: Basic – Build an alert system that activates a warning LED when either a local or remote signal is triggered.

Objective and use case

In this practical case, you will build a digital alarm indicator utilizing a 74HC32 logic OR gate. The circuit combines two independent input signals (representing a local sensor and a remote sensor) so that if either one or both are activated, the output will drive an alert LED.

Why this circuit is useful:
* Security systems: A single alarm panel can monitor both a front door and a back door.
* Industrial safety: A machine can be halted by either a local emergency stop button or a remote operator console.
* Environmental monitoring: A system can trigger a unified warning if either a smoke detector or a heat sensor detects an anomaly.

Expected outcome:
* With both switches open (0 V at inputs), the output is 0 V and the LED is off.
* Closing the local switch yields 5 V at the first input, forcing the output to 5 V and turning on the LED.
* Closing the remote switch yields 5 V at the second input, forcing the output to 5 V and turning on the LED.
* Closing both switches simultaneously yields 5 V at both inputs, maintaining the 5 V output and keeping the LED illuminated.

Target audience and level: Beginners and hobbyists learning basic digital logic concepts.

Materials

  • U1: 74HC32 quad 2-input OR gate, function: logic control
  • V1: 5 V DC supply, function: power source
  • SW1: SPST switch, function: local alarm trigger
  • SW2: SPST switch, function: remote alarm trigger
  • R1: 10 kΩ resistor, function: pull-down for VA
  • R2: 10 kΩ resistor, function: pull-down for VB
  • R3: 330 Ω resistor, function: LED current limiting
  • D1: red LED, function: alarm indicator

Pin-out of the IC used

74HC32 (Quad 2-input OR gate)

Pin Name Logic function Connection in this case
1 1 A Input 1 for Gate 1 Connects to node VA (from SW1)
2 1B Input 2 for Gate 1 Connects to node VB (from SW2)
3 1Y Output of Gate 1 Connects to node VOUT
7 GND Ground / 0 V reference Connects to node 0
14 VCC Positive supply voltage Connects to node VCC

(Note: Pins 4, 5, 6, 8, 9, 10, 11, 12, and 13 belong to the other three unused OR gates in the package and should ideally have their inputs tied to ground in a permanent design, though they are left out of this primary signal path for simplicity).

Wiring guide

  • V1: Positive terminal connects to node VCC, negative terminal connects to node 0.
  • SW1: Connects between node VCC and node VA.
  • SW2: Connects between node VCC and node VB.
  • R1: Connects between node VA and node 0.
  • R2: Connects between node VB and node 0.
  • U1: Pin 14 connects to node VCC, Pin 7 connects to node 0. Pin 1 connects to node VA, Pin 2 connects to node VB, Pin 3 connects to node VOUT.
  • R3: Connects between node VOUT and node VLED.
  • D1: Anode connects to node VLED, cathode connects to node 0.

Conceptual block diagram

Conceptual block diagram — PUERTA OR gate
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

VCC --> [ SW1: Local Alarm ] --(VA)-->+---------------------------------> [           ]
                                      |                                   [ U1: Pin 1 ]
                                      +--> [ R1: 10 kΩ Pull-down ] --> GND [           ]
                                                                          [  74HC32   ] --(VOUT)--> [ R3: 330 Ω ] --(VLED)--> [ D1: Red LED ] --> GND
VCC --> [ SW2: Remote Alarm] --(VB)-->+---------------------------------> [  OR Gate  ]
                                      |                                   [           ]
                                      +--> [ R2: 10 kΩ Pull-down ] --> GND [ U1: Pin 2 ]
                                                                          [           ]
Electrical Schematic

Truth table

Local Signal (VA) Remote Signal (VB) Output (VOUT) Alarm LED (D1)
0 (Low) 0 (Low) 0 (Low) OFF
0 (Low) 1 (High) 1 (High) ON
1 (High) 0 (Low) 1 (High) ON
1 (High) 1 (High) 1 (High) ON

Measurements and tests

  1. Input Verification: Using a digital multimeter (DMM) referenced to node 0, measure the voltage at nodes VA and VB. Verify that they read approximately 0 V when the respective switch is open, and 5 V when closed.
  2. Output Verification: Measure the voltage at node VOUT. Confirm that it reads 0 V only when both VA and VB are at 0 V. If either or both inputs are at 5 V, VOUT must measure close to 5 V.
  3. Visual Confirmation: Toggle SW1 and SW2 through all four possible combinations as listed in the truth table and confirm D1 behaves accordingly.
  4. Current Measurement (Optional): Place your DMM in series with R3 to measure the LED forward current. It should be approximately 8-10 mA depending on the LED’s forward voltage drop.

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Dual Input Alarm System using OR Gate
.width out=256

* Power Supply
V1 VCC 0 DC 5

* Local Alarm Trigger (SW1)
* Modeled as a voltage-controlled switch driven by a pulse to simulate user interaction
SW1 VCC VA ctrl1 0 mySW
Vctrl1 ctrl1 0 PULSE(0 5 0 1u 1u 50u 100u)

* Remote Alarm Trigger (SW2)
* Modeled as a voltage-controlled switch driven by a pulse to simulate user interaction
SW2 VCC VB ctrl2 0 mySW
Vctrl2 ctrl2 0 PULSE(0 5 0 1u 1u 100u 200u)

* Switch Model
.model mySW SW(Ron=1 Roff=100Meg Vt=2.5)

* Pull-down resistors
* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

* Dual Input Alarm System using OR Gate
.width out=256

* Power Supply
V1 VCC 0 DC 5

* Local Alarm Trigger (SW1)
* Modeled as a voltage-controlled switch driven by a pulse to simulate user interaction
SW1 VCC VA ctrl1 0 mySW
Vctrl1 ctrl1 0 PULSE(0 5 0 1u 1u 50u 100u)

* Remote Alarm Trigger (SW2)
* Modeled as a voltage-controlled switch driven by a pulse to simulate user interaction
SW2 VCC VB ctrl2 0 mySW
Vctrl2 ctrl2 0 PULSE(0 5 0 1u 1u 100u 200u)

* Switch Model
.model mySW SW(Ron=1 Roff=100Meg Vt=2.5)

* Pull-down resistors
R1 VA 0 10k
R2 VB 0 10k

* 74HC32 Quad 2-input OR gate (using 1 gate)
XU1 VA VB VOUT 0 VCC U_74HC32_OR

* Robust Subcircuit for 74HC32 OR Gate using continuous math functions
.subckt U_74HC32_OR P1 P2 P3 P7 P14
B1 P3 P7 V = V(P14,P7) * (1 - (1 / (1 + exp(50*(V(P1,P7)-V(P14,P7)/2)))) * (1 / (1 + exp(50*(V(P2,P7)-V(P14,P7)/2)))))
.ends

* Output Indicator
R3 VOUT VLED 330
D1 VLED 0 DLED
.model DLED D(IS=1e-15 N=1.8 RS=10)

* Analysis Commands
.tran 1u 300u
.print tran V(VA) V(VB) V(VOUT) V(VLED)
.op

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The transient analysis spans 0 s to 300 us and captures the switching interval. Main ranges: v(vout) 2.77e-62 uV -> 5 V; v(va) 500 uV -> 5 V; v(vb) 500 uV -> 5 V.
Show raw data table (412 rows)
Index   time            v(va)           v(vb)           v(vout)         v(vled)
0	0.000000e+00	4.999500e-04	4.999500e-04	2.767481e-68	5.488664e-30
1	1.000000e-08	4.999500e-04	4.999500e-04	2.767481e-68	4.008316e-41
2	2.000000e-08	4.999500e-04	4.999500e-04	2.767481e-68	-4.00832e-41
3	4.000000e-08	4.999500e-04	4.999500e-04	2.767481e-68	-1.46362e-51
4	8.000000e-08	4.999500e-04	4.999500e-04	2.767481e-68	5.854466e-52
5	1.600000e-07	4.999500e-04	4.999500e-04	2.767481e-68	3.420369e-62
6	3.200000e-07	4.999500e-04	4.999500e-04	2.767481e-68	-8.55089e-63
7	3.562500e-07	4.999500e-04	4.999500e-04	2.767481e-68	2.767467e-68
8	4.196875e-07	4.999500e-04	4.999500e-04	2.767481e-68	2.767492e-68
9	4.372461e-07	4.999500e-04	4.999500e-04	2.767481e-68	2.767481e-68
10	4.679736e-07	4.999500e-04	4.999500e-04	2.767481e-68	2.767481e-68
11	5.019934e-07	4.999500e+00	4.999500e+00	5.000000e+00	1.503225e+00
12	5.700330e-07	4.999500e+00	4.999500e+00	5.000000e+00	1.502641e+00
13	7.061121e-07	4.999500e+00	4.999500e+00	5.000000e+00	1.502321e+00
14	9.782703e-07	4.999500e+00	4.999500e+00	5.000000e+00	1.502318e+00
15	1.000000e-06	4.999500e+00	4.999500e+00	5.000000e+00	1.502314e+00
16	1.043459e-06	4.999500e+00	4.999500e+00	5.000000e+00	1.502314e+00
17	1.130378e-06	4.999500e+00	4.999500e+00	5.000000e+00	1.502314e+00
18	1.304216e-06	4.999500e+00	4.999500e+00	5.000000e+00	1.502314e+00
19	1.651892e-06	4.999500e+00	4.999500e+00	5.000000e+00	1.502314e+00
20	2.347244e-06	4.999500e+00	4.999500e+00	5.000000e+00	1.502314e+00
21	3.347244e-06	4.999500e+00	4.999500e+00	5.000000e+00	1.502314e+00
22	4.347244e-06	4.999500e+00	4.999500e+00	5.000000e+00	1.502314e+00
23	5.347244e-06	4.999500e+00	4.999500e+00	5.000000e+00	1.502314e+00
... (388 more rows) ...


Reference SPICE netlist (ngspice)

* Dual Input Alarm System using OR Gate
.width out=256

* Power Supply
V1 VCC 0 DC 5

* Local Alarm Trigger (SW1)
* Modeled as a voltage-controlled switch driven by a pulse to simulate user interaction
SW1 VCC VA ctrl1 0 mySW
Vctrl1 ctrl1 0 PULSE(0 5 0 1u 1u 50u 100u)

* Remote Alarm Trigger (SW2)
* Modeled as a voltage-controlled switch driven by a pulse to simulate user interaction
SW2 VCC VB ctrl2 0 mySW
Vctrl2 ctrl2 0 PULSE(0 5 0 1u 1u 100u 200u)

* Switch Model
.model mySW SW(Ron=1 Roff=100Meg Vt=2.5)

* Pull-down resistors
R1 VA 0 10k
R2 VB 0 10k

* 74HC32 Quad 2-input OR gate (using 1 gate)
XU1 VA VB VOUT 0 VCC U_74HC32_OR

* Robust Subcircuit for 74HC32 OR Gate using continuous math functions
.subckt U_74HC32_OR P1 P2 P3 P7 P14
B1 P3 P7 V = V(P14,P7) * (1 - (1 / (1 + exp(50*(V(P1,P7)-V(P14,P7)/2)))) * (1 / (1 + exp(50*(V(P2,P7)-V(P14,P7)/2)))))
.ends

* Output Indicator
R3 VOUT VLED 330
D1 VLED 0 DLED
.model DLED D(IS=1e-15 N=1.8 RS=10)

* Analysis Commands
.tran 1u 300u
.print tran V(VA) V(VB) V(VOUT) V(VLED)
.op

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The transient analysis spans 0 s to 300 us and captures the switching interval. Main ranges: v(vout) 2.77e-62 uV -> 5 V; v(va) 500 uV -> 5 V; v(vb) 500 uV -> 5 V.

Common mistakes and how to avoid them

  1. Floating inputs: Forgetting to connect the pull-down resistors (R1 and R2). Without them, when the switches are open, the 74HC32 inputs act like antennas and will cause the output to randomly toggle or oscillate. Always use pull-down resistors.
  2. Missing LED current limiting resistor: Connecting the LED directly from the output pin (node VOUT) to ground. This will draw excessive current, potentially burning out both the LED and the 74HC32 output stage. Always include R3.
  3. Forgetting IC power connections: Wiring the inputs and outputs but forgetting to supply VCC to pin 14 and GND to pin 7. The IC cannot function without its power rails connected.


Troubleshooting

  • Symptom: The LED is always ON, regardless of switch positions.
    • Cause: Inputs are permanently shorted to VCC, or switches are wired as «Normally Closed».
    • Fix: Verify that the switches only bridge VCC to the inputs when actively pressed. Ensure nodes VA and VB measure 0 V when switches are released.
  • Symptom: The LED never turns ON.
    • Cause: LED D1 is inserted backwards (reversed polarity), or the IC is not powered.
    • Fix: Check the orientation of D1 (anode to R3, cathode to ground). Measure pin 14 on U1 to guarantee it receives 5 V.
  • Symptom: The LED flickers when you move your hand near the circuit.
    • Cause: The inputs are floating. CMOS chips have highly sensitive inputs.
    • Fix: Check the connections of R1 and R2. Ensure they securely tie nodes VA and VB to ground when the switches are open.

Possible improvements and extensions

  1. Audible alert integration: Add an active 5 V piezoelectric buzzer in parallel with the LED/resistor combination (connecting the buzzer’s positive lead to VOUT and the negative lead to node 0) to provide both a visual and audible alarm.
  2. Expand to a 3-input alarm: Utilize a second OR gate inside the same 74HC32 chip. Connect VOUT to Pin 4 (2 A), a third switch/pull-down assembly to Pin 5 (2B), and use Pin 6 (2Y) to drive the LED, creating a system that monitors three distinct zones.

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: What is the main logic gate used in this alert system?




Question 2: What condition turns the warning LED off?




Question 3: What voltage represents an open switch at the inputs in this circuit?




Question 4: What happens to the LED if only the local switch is closed?




Question 5: Which of the following is a mentioned use case for this circuit?




Question 6: In the environmental monitoring example, what two sensors are combined?




Question 7: What is the output voltage when both switches are closed simultaneously?




Question 8: How many independent input signals does this specific circuit combine?




Question 9: What does the output of the 74HC32 gate drive in this practical case?




Question 10: In a security system application, what could the two inputs represent?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:


Practical case: Nurse call bell

Nurse call bell prototype (Maker Style)

Level: Basic – Implement an OR gate to activate an alert from two independent switches.

Objective and use case

You will build a basic nurse call circuit using a digital OR gate to trigger a visual alert whenever either of two patient bed switches is pressed.

Why it is useful:
* Allows centralized monitoring of multiple independent trigger points.
* Demonstrates how basic digital logic simplifies parallel alarm systems without cross-wiring physical switches.
* Forms the foundation for larger, more complex call bell or security systems.

Expected outcome:
* Pressing switch A drives the output HIGH (near 5 V), lighting the LED.
* Pressing switch B drives the output HIGH (near 5 V), lighting the LED.
* Pressing both switches simultaneously drives the output HIGH, lighting the LED.
* The output remains LOW (0 V) and the LED stays off when no switches are pressed.

Target audience and level: Beginners learning digital logic gates and the importance of pull-down networks.

Materials

  • V1: 5 V DC supply
  • U1: 74HC32 quad 2-input OR gate IC
  • SW1: Push button switch, normally open, function: Bed A trigger
  • SW2: Push button switch, normally open, function: Bed B trigger
  • R1: 10 kΩ resistor, function: pull-down for VA
  • R2: 10 kΩ resistor, function: pull-down for VB
  • R3: 330 Ω resistor, function: LED current limiting
  • D1: Red LED, function: alert indicator

Pin-out of the IC used

74HC32 (Quad 2-Input OR Gate)

Pin Name Logic function Connection in this case
1 1 A Input 1 for Gate 1 Node VA (Switch A)
2 1B Input 2 for Gate 1 Node VB (Switch B)
3 1Y Output of Gate 1 Node VOUT (to LED circuit)
7 GND Ground Node 0
14 VCC Power Supply Node VCC

(Note: Pins 4, 5, 8, 9, 10, 11, 12, 13 are unused inputs and should be tied to Ground in a permanent circuit to prevent CMOS latch-up).

Wiring guide

  • V1: positive terminal connects to VCC; negative terminal connects to 0.
  • SW1: connects between VCC and VA.
  • SW2: connects between VCC and VB.
  • R1: connects between VA and 0.
  • R2: connects between VB and 0.
  • U1 (pin 14): connects to VCC.
  • U1 (pin 7): connects to 0.
  • U1 (pin 1): connects to VA.
  • U1 (pin 2): connects to VB.
  • U1 (pin 3): connects to VOUT.
  • R3: connects between VOUT and the anode of D1.
  • D1: cathode connects to 0.

Conceptual block diagram

Conceptual block diagram — 74HC32 OR gate
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

VCC --> [ SW1: Bed A ] --(VA)--> [ R1: 10 kΩ Pull-down ] --> GND
                             \
                              -->(Pin 1) \
                                          [ U1: 74HC32 OR Gate ] --(VOUT, Pin 3)--> [ R3: 330 Ω ] --> [ D1: Red LED ] --> GND
                                          /
                              -->(Pin 2) /
                             /
VCC --> [ SW2: Bed B ] --(VB)--> [ R2: 10 kΩ Pull-down ] --> GND
Electrical Schematic

Truth table

Input A (VA) Input B (VB) Output Y (VOUT) LED State
0 (LOW) 0 (LOW) 0 (LOW) OFF
0 (LOW) 1 (HIGH) 1 (HIGH) ON
1 (HIGH) 0 (LOW) 1 (HIGH) ON
1 (HIGH) 1 (HIGH) 1 (HIGH) ON

Measurements and tests

  1. Power Verification: Measure the voltage between VCC and 0 using a multimeter to ensure it is exactly 5 V.
  2. Idle State Testing: Without pressing any buttons, measure the voltage at nodes VA and VB. Both should read exactly 0 V. The node VOUT should also read 0 V.
  3. Logic HIGH Testing: Press and hold SW1. Measure node VA (should be ~5 V) and measure node VOUT (should be ~5 V). Verify the LED is ON. Repeat this process for SW2 and node VB.
  4. Current Measurement (Optional): Place your multimeter in series with R3 and D1 to measure the forward current of the LED (it should be roughly 8-10 mA depending on the LED’s forward voltage drop).

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Practical case: Nurse call bell
.width out=256

* Power Supply
V1 VCC 0 DC 5

* Bed A Trigger (SW1)
* Modeled as a voltage-controlled switch activated by a pulse to simulate a user pressing the button
VctrlA ctrlA 0 PULSE(0 5 10u 1u 1u 40u 100u)
S1 VCC VA ctrlA 0 my_switch

* Bed B Trigger (SW2)
* Modeled as a voltage-controlled switch activated by a pulse to simulate a user pressing the button
VctrlB ctrlB 0 PULSE(0 5 10u 1u 1u 90u 200u)
S2 VCC VB ctrlB 0 my_switch

* Pull-down resistors for switch inputs
R1 VA 0 10k
R2 VB 0 10k

* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

* Practical case: Nurse call bell
.width out=256

* Power Supply
V1 VCC 0 DC 5

* Bed A Trigger (SW1)
* Modeled as a voltage-controlled switch activated by a pulse to simulate a user pressing the button
VctrlA ctrlA 0 PULSE(0 5 10u 1u 1u 40u 100u)
S1 VCC VA ctrlA 0 my_switch

* Bed B Trigger (SW2)
* Modeled as a voltage-controlled switch activated by a pulse to simulate a user pressing the button
VctrlB ctrlB 0 PULSE(0 5 10u 1u 1u 90u 200u)
S2 VCC VB ctrlB 0 my_switch

* Pull-down resistors for switch inputs
R1 VA 0 10k
R2 VB 0 10k

* U1: 74HC32 quad 2-input OR gate IC (using 1 gate)
* Wiring: Pin 1 -> VA, Pin 2 -> VB, Pin 3 -> VOUT, Pin 14 -> VCC, Pin 7 -> 0
XU1 VA VB VOUT VCC 0 74HC32_OR

* Alert Indicator (LED and current limiting resistor)
R3 VOUT D1_A 330
D1 D1_A 0 DLED

* --- Models and Subcircuits ---

* Ideal switch model
.model my_switch SW(vt=2.5 vh=0.5 ron=1 roff=100MEG)

* Generic Red LED model
.model DLED D(IS=1e-20 N=2.2 RS=2)

* Behavioral model for a 74HC32 OR gate (Continuous functions for robust convergence)
.subckt 74HC32_OR A B Y VCC GND
RinA A GND 10MEG
RinB B GND 10MEG
* OR Logic: V_out = VCC * (1 - (1-A)*(1-B)) implemented with sigmoids
B1 Y_int GND V = V(VCC) * (1 - (1 - 1/(1+exp(-50*(V(A)-2.5)))) * (1 - 1/(1+exp(-50*(V(B)-2.5)))))
Rout Y_int Y 10
.ends

* --- Analysis Directives ---

.tran 1u 250u
.print tran V(VA) V(VB) V(VOUT) V(D1_A)
.op
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The transient analysis spans 0 s to 250 us and captures the switching interval. Main ranges: v(vout) -1.01e-29 uV -> 4.92 V; v(va) 499 uV -> 5 V; v(vb) 499 uV -> 5 V.
Show raw data table (354 rows)
Index   time            v(va)           v(vb)           v(vout)         v(d1_a)
0	0.000000e+00	4.994506e-04	4.994506e-04	-1.00582e-35	-3.41977e-34
1	1.000000e-08	4.994506e-04	4.994506e-04	-6.04520e-52	-2.05537e-50
2	2.000000e-08	4.994506e-04	4.994506e-04	6.045198e-52	2.055367e-50
3	4.000000e-08	4.994506e-04	4.994506e-04	1.816637e-67	6.176631e-66
4	8.000000e-08	4.994506e-04	4.994506e-04	-7.26682e-68	-2.47066e-66
5	1.600000e-07	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
6	3.200000e-07	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
7	6.400000e-07	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
8	1.280000e-06	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
9	2.280000e-06	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
10	3.280000e-06	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
11	4.280000e-06	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
12	5.280000e-06	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
13	6.280000e-06	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
14	7.280000e-06	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
15	8.280000e-06	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
16	9.280000e-06	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
17	1.000000e-05	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
18	1.010000e-05	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
19	1.030000e-05	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
20	1.035875e-05	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
21	1.046156e-05	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
22	1.049002e-05	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
23	1.053982e-05	4.994506e-04	4.994506e-04	-1.94609e-72	-1.94609e-72
... (330 more rows) ...


Reference SPICE netlist (ngspice)

* Practical case: Nurse call bell
.width out=256

* Power Supply
V1 VCC 0 DC 5

* Bed A Trigger (SW1)
* Modeled as a voltage-controlled switch activated by a pulse to simulate a user pressing the button
VctrlA ctrlA 0 PULSE(0 5 10u 1u 1u 40u 100u)
S1 VCC VA ctrlA 0 my_switch

* Bed B Trigger (SW2)
* Modeled as a voltage-controlled switch activated by a pulse to simulate a user pressing the button
VctrlB ctrlB 0 PULSE(0 5 10u 1u 1u 90u 200u)
S2 VCC VB ctrlB 0 my_switch

* Pull-down resistors for switch inputs
R1 VA 0 10k
R2 VB 0 10k

* U1: 74HC32 quad 2-input OR gate IC (using 1 gate)
* Wiring: Pin 1 -> VA, Pin 2 -> VB, Pin 3 -> VOUT, Pin 14 -> VCC, Pin 7 -> 0
XU1 VA VB VOUT VCC 0 74HC32_OR

* Alert Indicator (LED and current limiting resistor)
R3 VOUT D1_A 330
D1 D1_A 0 DLED

* --- Models and Subcircuits ---

* Ideal switch model
.model my_switch SW(vt=2.5 vh=0.5 ron=1 roff=100MEG)

* Generic Red LED model
.model DLED D(IS=1e-20 N=2.2 RS=2)

* Behavioral model for a 74HC32 OR gate (Continuous functions for robust convergence)
.subckt 74HC32_OR A B Y VCC GND
RinA A GND 10MEG
RinB B GND 10MEG
* OR Logic: V_out = VCC * (1 - (1-A)*(1-B)) implemented with sigmoids
B1 Y_int GND V = V(VCC) * (1 - (1 - 1/(1+exp(-50*(V(A)-2.5)))) * (1 - 1/(1+exp(-50*(V(B)-2.5)))))
Rout Y_int Y 10
.ends

* --- Analysis Directives ---

.tran 1u 250u
.print tran V(VA) V(VB) V(VOUT) V(D1_A)
.op
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The transient analysis spans 0 s to 250 us and captures the switching interval. Main ranges: v(vout) -1.01e-29 uV -> 4.92 V; v(va) 499 uV -> 5 V; v(vb) 499 uV -> 5 V.

Common mistakes and how to avoid them

  • Floating inputs: Forgetting the pull-down resistors (R1 and R2). Without them, the voltage at the gate inputs will float when the switches are open, causing random, unpredictable triggering of the alarm.
  • Omitting power connections to the IC: Forgetting to connect pins 7 and 14 to Ground and VCC, respectively. The logic gate cannot function without its own power supply.
  • Leaving unused CMOS inputs floating: The 74HC32 is a CMOS device. Any unused input pins (e.g., pins 4, 5, 9, 10, 12, 13) should be tied to Ground (0) to prevent excess power consumption or erratic behavior.


Troubleshooting

  • Symptom: The LED stays ON constantly, even when no buttons are pressed.
  • Cause: One of the pull-down resistors (R1 or R2) is missing or not properly connected to ground.
  • Fix: Verify the connection of the resistors between inputs VA or VB and node 0.
  • Symptom: The LED never turns ON.
  • Cause: LED is installed backward, missing VCC/GND to the IC, or a disconnected R3.
  • Fix: Check LED polarity (flat side / shorter leg goes to node 0). Ensure pins 7 and 14 on U1 have power.
  • Symptom: The LED turns ON randomly when my hand is near the breadboard.
  • Cause: The circuit is experiencing a «floating input» acting as an antenna picking up stray capacitance.
  • Fix: Check your pull-down resistors. Make sure they firmly connect the input pins to ground.
  • Symptom: Output is logic HIGH (measured at pin 3), but LED is extremely dim.
  • Cause: The current limiting resistor R3 is too large (e.g., 10 kΩ instead of 330 Ω).
  • Fix: Replace R3 with the correct 330 Ω value.

Possible improvements and extensions

  • Add an audible alert: Connect an active 5 V buzzer in parallel with the LED/resistor combination so that triggering the switch produces both a light and a sound.
  • Implement a latching circuit: In a real hospital, the light must stay ON until a nurse arrives to reset it. Feed the output of the OR gate into the SET pin of an SR Latch (or use logic gates to build one), and add a third «Reset» button at the nurse station.

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: What is the main objective of the circuit described in the article?




Question 2: Which type of digital logic gate is used to trigger the visual alert in this circuit?




Question 3: What happens to the output when neither switch is pressed?




Question 4: What is the expected outcome if both patient bed switches are pressed simultaneously?




Question 5: Which IC model is used as the quad 2-input OR gate in this project?




Question 6: Which IC model is used as the quad 2-input OR gate in this project?




Question 7: Which IC model is used as the quad 2-input OR gate in this project?




Question 8: Which IC model is used as the quad 2-input OR gate in this project?




Question 9: Which IC model is used as the quad 2-input OR gate in this project?




Question 10: Which IC model is used as the quad 2-input OR gate in this project?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:


Practical case: Emergency water pump activation

Emergency water pump activation prototype (Maker Style)

Level: Basic. Design a control system that activates a drainage pump if either of two water level sensors is triggered.

Objective and use case

You will build a logic control circuit using a 74HC32 (OR Gate) to drive a DC motor via a transistor driver whenever water is detected by at least one sensor.

Why it is useful:
* Flood Prevention: Automatically activates a sump pump in a basement when water rises to a critical level.
* Industrial Safety: Prevents tank overflows by draining liquid if primary or secondary high-level sensors are triggered.
* Marine Applications: Activates a boat’s bilge pump if water enters the hull from either the port or starboard side.
* Redundancy: Ensures the pump starts even if one sensor fails (provided the other detects the water).

Expected outcome:
* The motor turns ON if Sensor A is HIGH.
* The motor turns ON if Sensor B is HIGH.
* The motor turns ON if both sensors are HIGH.
* The logic output at the gate pin reads ~5 V (Logic 1) when active.
* Target audience: Basic electronics students and hobbyists.

Materials

  • V1: 5 V DC supply, function: Main circuit power.
  • S1: SPST Switch, function: Simulates Water Level Sensor A.
  • S2: SPST Switch, function: Simulates Water Level Sensor B.
  • R1: 10 kΩ resistor, function: Pull-down for Sensor A.
  • R2: 10 kΩ resistor, function: Pull-down for Sensor B.
  • U1: 74HC32 Quad 2-Input OR Gate.
  • R3: 1 kΩ resistor, function: Transistor base current limiting.
  • Q1: 2N2222 NPN Transistor, function: Motor driver switch.
  • D1: 1N4007 Diode, function: Flyback protection (snubber).
  • M1: 5 V DC Motor, function: Drainage pump simulation.

Pin-out of the IC used

Chip: 74HC32 (Quad 2-Input OR Gate)

Pin Name Logic function Connection in this case
1 1A Input A Connected to Node SENS_A
2 1B Input B Connected to Node SENS_B
3 1Y Output Connected to Node GATE_OUT
7 GND Ground Connected to Node 0 (GND)
14 VCC Power (+5V) Connected to Node VCC

Wiring guide

Construct the circuit following these node connections:

  • VCC: Connect positive terminal of V1, one side of S1, one side of S2, Pin 14 of U1, and the positive terminal of M1.
  • 0 (GND): Connect negative terminal of V1, Pin 7 of U1, Emitter of Q1, bottom of R1, and bottom of R2.
  • SENS_A: Connect other side of S1, top of R1, and Pin 1 of U1.
  • SENS_B: Connect other side of S2, top of R2, and Pin 2 of U1.
  • GATE_OUT: Connect Pin 3 of U1 to one side of R3.
  • BASE_NODE: Connect the other side of R3 to the Base of Q1.
  • MOTOR_DRIVE: Connect the Collector of Q1, the negative terminal of M1, and the Anode of D1.
  • PROTECTION: Connect the Cathode of D1 to VCC (Across the motor).

Conceptual block diagram

Conceptual block diagram — 74HC32 OR gate

Schematic

[ INPUTS / SENSORS ]                 [ LOGIC CONTROL ]                   [ ACTUATOR / OUTPUT ]

                                          +----------------+
    [ Switch S1 ]                         |                |
    [ + R1 (PD) ] --(SENS_A / Pin 1)----->|   U1: 74HC32   |
                                          |   (OR Gate)    |
                                          |                |--(GATE_OUT / Pin 3)--> [ Resistor R3 ]
                                          |   Logic:       |                            |
    [ Switch S2 ]                         |   If A OR B    |                            |
    [ + R2 (PD) ] --(SENS_B / Pin 2)----->|   Then HIGH    |                            |
                                          |                |                      (BASE_NODE)
                                          +----------------+                            |
                                                                                        v
                                                                               [ Q1 NPN Transistor ]
                                                                               (Electronic Switch)
                                                                                        |
                                                                                        | (Switches GND)
                                                                                        |
                                                                                  (MOTOR_DRIVE)
                                                                                        |
                                                                                        v
                                                                             [ Motor M1 + Diode D1 ]
                                                                             (Connected to VCC)
Schematic (ASCII)

Electrical diagram

Electrical diagram for case: Practical case: Emergency water pump activation
Generated from the validated SPICE netlist for this case.

🔒 This electrical diagram is premium. With the monthly membership (7-day free trial) you can unlock the complete didactic material and the print-ready PDF pack.🔓 See premium access plans

Truth table

This table describes the logic state of the 74HC32 and the resulting physical action of the pump.

Sensor A (Input 1A) Sensor B (Input 1B) Logic Output (Pin 1Y) Transistor State Pump Status
Low (0) Low (0) Low (0) OFF (Open) OFF
Low (0) High (1) High (1) ON (Saturation) ON
High (1) Low (0) High (1) ON (Saturation) ON
High (1) High (1) High (1) ON (Saturation) ON

Measurements and tests

  1. Power Check: Before connecting the motor, measure the voltage between VCC and GND. It should be stable at 5 V.
  2. Idle State: Ensure both switches are open. Measure voltage at Pin 3 (GATE_OUT). It should be ~0 V. The motor should be stopped.
  3. Sensor A Activation: Close S1. Measure voltage at Pin 1 (Input A). It should be 5 V. Pin 3 should go High, and the motor should spin.
  4. Sensor B Activation: Open S1 and close S2. Verify the motor spins.
  5. Simultaneous Activation: Close both S1 and S2. The motor should remain spinning.
  6. Current Draw: Place an ammeter in series with the motor. Note the current consumption (typically 50mA to 200mA for small hobby motors).

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Emergency water pump activation fixed

* --- Power Supply ---
V1 VCC 0 DC 5

* --- Switches & Sensors ---
* S1: Simulates Water Level Sensor A
V_ACT_A ACT_A 0 PULSE(0 5 0 1u 1u 1m 2m)
S1 VCC SENS_A ACT_A 0 SW_MOD

* R1: Pull-down for Sensor A
R1 SENS_A 0 10k

* S2: Simulates Water Level Sensor B
V_ACT_B ACT_B 0 PULSE(0 5 0 1u 1u 0.5m 1m)
S2 VCC SENS_B ACT_B 0 SW_MOD

* R2: Pull-down for Sensor B
R2 SENS_B 0 10k

* --- Logic Gate U1: 74HC32 (Quad OR) ---
* Pin 1: SENS_A, Pin 2: SENS_B, Pin 3: GATE_OUT, Pin 7: GND, Pin 14: VCC
XU1 SENS_A SENS_B GATE_OUT 0 VCC 74HC32_GATE

* --- Driver Stage ---
* R3: Base resistor
R3 GATE_OUT BASE_NODE 1k

* Q1: NPN Transistor Switch
* Collector: MOTOR_DRIVE, Base: BASE_NODE, Emitter: 0 (GND)
* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

🔒 Part of this section is premium. With the monthly membership (7-day free trial) you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* Emergency water pump activation fixed

* --- Power Supply ---
V1 VCC 0 DC 5

* --- Switches & Sensors ---
* S1: Simulates Water Level Sensor A
V_ACT_A ACT_A 0 PULSE(0 5 0 1u 1u 1m 2m)
S1 VCC SENS_A ACT_A 0 SW_MOD

* R1: Pull-down for Sensor A
R1 SENS_A 0 10k

* S2: Simulates Water Level Sensor B
V_ACT_B ACT_B 0 PULSE(0 5 0 1u 1u 0.5m 1m)
S2 VCC SENS_B ACT_B 0 SW_MOD

* R2: Pull-down for Sensor B
R2 SENS_B 0 10k

* --- Logic Gate U1: 74HC32 (Quad OR) ---
* Pin 1: SENS_A, Pin 2: SENS_B, Pin 3: GATE_OUT, Pin 7: GND, Pin 14: VCC
XU1 SENS_A SENS_B GATE_OUT 0 VCC 74HC32_GATE

* --- Driver Stage ---
* R3: Base resistor
R3 GATE_OUT BASE_NODE 1k

* Q1: NPN Transistor Switch
* Collector: MOTOR_DRIVE, Base: BASE_NODE, Emitter: 0 (GND)
Q1 MOTOR_DRIVE BASE_NODE 0 2N2222MOD

* --- Output Load (Motor) ---
* M1: 5V DC Motor simulation (Inductive Load)
* Fixed: Subcircuit name changed from DC_MOTOR_MODEL to DC_MOTOR to match definition
XM1 VCC MOTOR_DRIVE DC_MOTOR

* --- Protection ---
* D1: Flyback Diode
D1 MOTOR_DRIVE VCC 1N4007MOD

* --- Models and Subcircuits ---

* Switch Model
.model SW_MOD SW(Vt=2.5 Vh=0.1 Ron=0.1 Roff=10Meg)

* Transistor Model (Generic 2N2222)
.model 2N2222MOD NPN(Is=14.34f Xti=3 Eg=1.11 Vaf=74.03 Bf=255.9 Ne=1.307 Ise=14.34f Ikf=.2847 Xtb=1.5 Br=6.092 Nc=2 Isc=0 Ikr=0 Rc=1 Cjc=7.306p Mjc=.3416 Vjc=.75 Fc=.5 Cje=22.01p Mje=.377 Vje=.75 Tr=46.91n Tf=411.1p Itf=.6 Vtf=1.7 Xtf=3 Rb=10)

* Diode Model (Generic 1N4007)
.model 1N4007MOD D(IS=7.027n RS=0.03415 N=1.267 EG=1.11 XTI=3 BV=1000 IBV=10m CJO=10p VJ=0.7 M=0.5 FC=0.5 TT=100n)

* Motor Model (Simple RL series)
.subckt DC_MOTOR POS NEG
Rcoil POS INT 50
Lcoil INT NEG 5m
.ends

* 74HC32 Logic Gate Model (Behavioral)
* Implements OR logic: OUT = 1 if (IN1=1 OR IN2=1)
.subckt 74HC32_GATE IN1 IN2 OUT GND VCC
B_OR OUT GND V=V(VCC) * ( (1/(1+exp(-20*(V(IN1)-2.5)))) + (1/(1+exp(-20*(V(IN2)-2.5)))) - ( (1/(1+exp(-20*(V(IN1)-2.5)))) * (1/(1+exp(-20*(V(IN2)-2.5)))) ) )
.ends

* --- Simulation Directives ---
.tran 10u 2.5m

* Print required nodes for validation
.print tran V(SENS_A) V(SENS_B) V(GATE_OUT) V(BASE_NODE) V(MOTOR_DRIVE)

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (2750 rows)
Index   time            v(sens_a)       v(sens_b)       v(gate_out)
0	0.000000e+00	4.995005e-03	4.995005e-03	2.131385e-21
1	1.000000e-08	4.995005e-03	4.995005e-03	2.131385e-21
2	2.000000e-08	4.995005e-03	4.995005e-03	2.131385e-21
3	4.000000e-08	4.995005e-03	4.995005e-03	2.131385e-21
4	8.000000e-08	4.995005e-03	4.995005e-03	2.131385e-21
5	1.600000e-07	4.995005e-03	4.995005e-03	2.131385e-21
6	3.200000e-07	4.995005e-03	4.995005e-03	2.131385e-21
7	3.600000e-07	4.995005e-03	4.995005e-03	2.131385e-21
8	4.300000e-07	4.995005e-03	4.995005e-03	2.131385e-21
9	4.493750e-07	4.995005e-03	4.995005e-03	2.131385e-21
10	4.832812e-07	4.995005e-03	4.995005e-03	2.131385e-21
11	5.162979e-07	4.999950e+00	4.999950e+00	5.000000e+00
12	5.395702e-07	4.999950e+00	4.999950e+00	5.000000e+00
13	5.611432e-07	4.999950e+00	4.999950e+00	5.000000e+00
14	5.884211e-07	4.999950e+00	4.999950e+00	5.000000e+00
15	6.429769e-07	4.999950e+00	4.999950e+00	5.000000e+00
16	7.520886e-07	4.999950e+00	4.999950e+00	5.000000e+00
17	9.703119e-07	4.999950e+00	4.999950e+00	5.000000e+00
18	1.000000e-06	4.999950e+00	4.999950e+00	5.000000e+00
19	1.030157e-06	4.999950e+00	4.999950e+00	5.000000e+00
20	1.090472e-06	4.999950e+00	4.999950e+00	5.000000e+00
21	1.211102e-06	4.999950e+00	4.999950e+00	5.000000e+00
22	1.452361e-06	4.999950e+00	4.999950e+00	5.000000e+00
23	1.934879e-06	4.999950e+00	4.999950e+00	5.000000e+00
... (2726 more rows) ...

Common mistakes and how to avoid them

  1. Floating Inputs: Forgetting the pull-down resistors (R1, R2).
    • Solution: Always connect inputs to ground via a resistor (10kΩ) so they default to 0 V when switches are open.
  2. Missing Flyback Diode: Omitting D1 across the motor.
    • Solution: Inductive loads generate voltage spikes when turned off. Always place a diode in reverse bias across the motor to protect the transistor.
  3. Overloading the Gate: Connecting the motor directly to the 74HC32 output pin.
    • Solution: Logic gates can only supply small currents (~20mA). Use a transistor (Q1) to handle the higher current required by the motor.

Troubleshooting

  • Symptom: Motor runs continuously even when switches are open.
    • Cause: Inputs are floating or the transistor is shorted.
    • Fix: Check R1/R2 connections or replace Q1.
  • Symptom: IC gets very hot immediately.
    • Cause: VCC and GND pins are reversed or shorted.
    • Fix: Disconnect power immediately and verify Pin 14 and Pin 7 wiring.
  • Symptom: Logic output is High (5V), but motor does not spin.
    • Cause: Base resistor (R3) too high or transistor gain too low.
    • Fix: Verify R3 is 1kΩ. Ensure the motor power supply is adequate.

Possible improvements and extensions

  1. Visual Indicators: Add an LED with a current-limiting resistor in parallel with the motor to provide a visual warning when the pump is active.
  2. Hysteresis/Latching: Replace the OR gate with an SR Latch logic. This would keep the pump running even if the water level drops momentarily, ensuring a full drain cycle until a bottom sensor resets it.

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: What is the primary objective of the control system described?




Question 2: Which logic gate IC is used to process the sensor inputs in this project?




Question 3: What component is typically used to simulate the digital input of water level sensors in this basic circuit?




Question 4: What is the function of the 1N4007 Diode (D1) placed across the motor?




Question 5: Under which condition will the motor turn ON?




Question 6: What is the purpose of the 10 kΩ resistors (R1 and R2) connected to the switches?




Question 7: Which component acts as the driver switch to handle the current for the DC motor?




Question 8: What is the expected logic output voltage at the gate pin when the system is active?




Question 9: Why is this system useful for marine applications like a bilge pump?




Question 10: What is the specific function of the resistor R3 (1 kΩ) connected to the transistor?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:


Practical case: Car Door Open Warning System

Car Door Open Warning System prototype (Maker Style)

Level: Basic – Implement a logic circuit that triggers an indicator when any door is left ajar.

Objective and use case

In this session, you will build a digital monitoring circuit using a 74HC32 OR gate to detect if any vehicle door is not fully closed. The circuit uses «Normally Closed» (NC) switches to simulate the door mechanics, ensuring that the alarm activates (LED turns ON) when a door opens.

  • Why it is useful:

    • Automotive Safety: Alerts drivers if a door is not latched before driving, preventing accidents.
    • Security Systems: Monitors multiple entry points (windows/doors) and triggers a central alarm if any single one is breached.
    • Industrial Enclosures: Ensures safety guards on dangerous machinery are closed before operation is allowed.
    • Access Control: Simple logic aggregation for multiple sensors.
  • Expected outcome:

    • Both Doors Closed: Inputs are Logic 0 (0 V); LED is OFF.
    • Door A Open: Input A becomes Logic 1 (5 V); LED turns ON.
    • Door B Open: Input B becomes Logic 1 (5 V); LED turns ON.
    • Both Open: Both inputs Logic 1; LED remains ON.
  • Target audience: Basic electronics students and automotive hobbyists.

Materials

  • V1: 5 V DC power supply, function: main circuit power.
  • S1: NC (Normally Closed) Pushbutton, function: Door A sensor (Released = Door Open).
  • S2: NC (Normally Closed) Pushbutton, function: Door B sensor (Released = Door Open).
  • R1: 10 kΩ resistor, function: pull-down for Input A.
  • R2: 10 kΩ resistor, function: pull-down for Input B.
  • U1: 74HC32, function: Quad 2-input OR gate IC.
  • R3: 330 Ω resistor, function: LED current limiting.
  • D1: Red LED, function: Open door warning indicator.
  • C1: 100 nF capacitor, function: decoupling for U1 power supply.

Pin-out of the IC used

Selected Chip: 74HC32 (Quad 2-Input OR Gate)

Pin Name Logic function Connection in this case
1 1A Input A Connected to Node DOOR_A
2 1B Input B Connected to Node DOOR_B
3 1Y Output Connected to Node V_ALARM
7 GND Ground Connected to Node 0
14 VCC Power Connected to Node VCC

Wiring guide

Follow these connections to create the SPICE-compatible netlist logic:

  • Power Supply

    • V1 connects between node VCC and node 0 (GND).
    • C1 connects between node VCC and node 0 (near the IC).
  • Input Stage (Door Sensors)

    • S1 connects between node VCC and node DOOR_A.
    • R1 connects between node DOOR_A and node 0. (Ensures Logic 0 when door is closed/switch pressed).
    • S2 connects between node VCC and node DOOR_B.
    • R2 connects between node DOOR_B and node 0.
  • Logic Processing (74HC32)

    • U1 Pin 14 connects to VCC.
    • U1 Pin 7 connects to 0.
    • U1 Pin 1 (Input 1A) connects to node DOOR_A.
    • U1 Pin 2 (Input 1B) connects to node DOOR_B.
    • U1 Pin 3 (Output 1Y) connects to node V_ALARM.
  • Output Stage (Indicator)

    • R3 connects between node V_ALARM and node LED_ANODE.
    • D1 anode connects to LED_ANODE.
    • D1 cathode connects to node 0.

Conceptual block diagram

Conceptual block diagram — 74HC32 OR gate

Schematic

[ INPUT STAGE ]                      [ LOGIC STAGE ]                  [ OUTPUT STAGE ]

(VCC 5V)
   |
[ S1: Door A Switch (NC) ]
   |
   +---> [ Node: DOOR_A ] --(Pin 1)---->+------------------+
   |                                    |                  |
[ R1: 10k Pull-Down ] -> GND            |    U1: 74HC32    |
                                        |    (OR Gate)     |
                                        |                  |--(Pin 3)---> [ R3: 330 Ohm ]
                                        |    Logic:        |                   |
(VCC 5V)                                |    A + B = Y     |                   v
   |                                    |                  |             [ D1: Red LED ]
[ S2: Door B Switch (NC) ]              |                  |                   |
   |                                    |                  |                  GND
   +---> [ Node: DOOR_B ] --(Pin 2)---->+------------------+
   |                                            ^
[ R2: 10k Pull-Down ] -> GND                    |
                                          [ C1: 100nF ]
                                          (Decoupling)
Schematic (ASCII)

Electrical diagram

Electrical diagram for case: Practical case: Car Door Open Warning System
Generated from the validated SPICE netlist for this case.

🔒 This electrical diagram is premium. With the monthly membership (7-day free trial) you can unlock the complete didactic material and the print-ready PDF pack.🔓 See premium access plans

Truth table

The 74HC32 behaves according to the standard OR logic. In this scenario:
* Logic 0 = 0 V (Door Closed / Switch Pressed).
* Logic 1 = 5 V (Door Open / Switch Released).

Door A (Input 1) Door B (Input 2) Output (LED) State Description
0 (Closed) 0 (Closed) 0 (OFF) Secure
0 (Closed) 1 (Open) 1 (ON) Warning
1 (Open) 0 (Closed) 1 (ON) Warning
1 (Open) 1 (Open) 1 (ON) Warning

Measurements and tests

  1. Supply Verification: Measure the voltage between VCC and 0. It should be stable at 5 V.
  2. Default State (Safe): Press and hold both S1 and S2 (simulating closed doors). Measure voltage at DOOR_A and DOOR_B. Both should be ~0 V. The LED should be OFF.
  3. Door A Test: Release S1 while holding S2. The voltage at DOOR_A should jump to ~5 V. The voltage at V_ALARM should go High (~5 V), and the LED should light up.
  4. Door B Test: Release S2 while holding S1. The voltage at DOOR_B should jump to ~5 V. The LED should light up.
  5. Logic Threshold Verification: If using a variable supply, verify that the 74HC32 registers a «High» signal once the input voltage crosses approximately 3.5 V (for 5 V VCC).

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Car Door Open Warning System
* Practical case implementation for ngspice

* --- Component Models ---
* Generic Red LED Model
.model DLED D(IS=10n N=2 RS=10 CJO=20p)
* Voltage Controlled Switch Model
* Vt=2.5V: Threshold voltage
* Ron=0.1: Resistance when ON (Closed)
* Roff=100Meg: Resistance when OFF (Open)
.model MYSW SW(Vt=2.5 Ron=0.1 Roff=100Meg)

* --- Power Supply ---
V1 VCC 0 DC 5

* --- Decoupling ---
C1 VCC 0 100n

* --- Input Stage: Door Sensors ---
* Logic: 
* S1/S2 are NC (Normally Closed) Pushbuttons.
* Function: Released = Door Open. Pressed = Door Closed.
* Wiring: S1 connects VCC to DOOR_A. R1 pulls DOOR_A to GND.
* Simulation Logic:
* We use Voltage Controlled Switches (S1, S2) to simulate the physical contacts.
* Control Pulses (V_ACT_A, V_ACT_B) simulate the "Door Open" state.
* High Pulse = Door Open = Switch Released (Closed contacts) -> VCC connected.
* Low Pulse = Door Closed = Switch Pressed (Open contacts) -> Pulled to 0V.

* Door A
* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

🔒 Part of this section is premium. With the monthly membership (7-day free trial) you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* Car Door Open Warning System
* Practical case implementation for ngspice

* --- Component Models ---
* Generic Red LED Model
.model DLED D(IS=10n N=2 RS=10 CJO=20p)
* Voltage Controlled Switch Model
* Vt=2.5V: Threshold voltage
* Ron=0.1: Resistance when ON (Closed)
* Roff=100Meg: Resistance when OFF (Open)
.model MYSW SW(Vt=2.5 Ron=0.1 Roff=100Meg)

* --- Power Supply ---
V1 VCC 0 DC 5

* --- Decoupling ---
C1 VCC 0 100n

* --- Input Stage: Door Sensors ---
* Logic: 
* S1/S2 are NC (Normally Closed) Pushbuttons.
* Function: Released = Door Open. Pressed = Door Closed.
* Wiring: S1 connects VCC to DOOR_A. R1 pulls DOOR_A to GND.
* Simulation Logic:
* We use Voltage Controlled Switches (S1, S2) to simulate the physical contacts.
* Control Pulses (V_ACT_A, V_ACT_B) simulate the "Door Open" state.
* High Pulse = Door Open = Switch Released (Closed contacts) -> VCC connected.
* Low Pulse = Door Closed = Switch Pressed (Open contacts) -> Pulled to 0V.

* Door A
S1 VCC DOOR_A CTRL_A 0 MYSW
R1 DOOR_A 0 10k

* Door B
S2 VCC DOOR_B CTRL_B 0 MYSW
R2 DOOR_B 0 10k

* --- Control Signals (User Stimuli) ---
* Timing Sequence:
* 0us - 100us: Both Doors Closed (Low)
* 100us - 200us: Door A Open (High)
* 200us - 300us: Both Doors Open (High)
* 300us - 400us: Door B Open (High)
* 400us - 600us: Both Doors Closed (Low)
V_ACT_A CTRL_A 0 PULSE(0 5 100u 1u 1u 200u 1000u)
V_ACT_B CTRL_B 0 PULSE(0 5 200u 1u 1u 200u 1000u)

* --- Logic Processing: U1 (74HC32) ---
* Quad 2-input OR gate
* Connections per wiring guide:
* Pin 1 (A) -> DOOR_A
* Pin 2 (B) -> DOOR_B
* Pin 3 (Y) -> V_ALARM
* Pin 7 (GND) -> 0
* Pin 14 (VCC) -> VCC
XU1 DOOR_A DOOR_B V_ALARM 0 VCC 74HC32

* --- Output Stage: Indicator ---
R3 V_ALARM LED_ANODE 330
D1 LED_ANODE 0 DLED

* --- Subcircuits ---
.subckt 74HC32 InA InB OutY GND VCC
* Behavioral OR Gate implementation
* Uses tanh for continuous, robust switching
* Logic: Out = VCC if (A > 2.5) OR (B > 2.5)
* Formula: Vout = VCC * ( 1 - (NOT A * NOT B) )
* NOT A is approximated by 0.5 * (1 - tanh(10*(V(InA)-2.5)))
B1 OutY GND V = V(VCC) * (1 - ( (0.5*(1-tanh(10*(V(InA)-2.5)))) * (0.5*(1-tanh(10*(V(InB)-2.5)))) ))
.ends

* --- Analysis Directives ---
.tran 1u 600u
.print tran V(DOOR_A) V(DOOR_B) V(V_ALARM) V(LED_ANODE)
.op

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (1382 rows)
Index   time            v(door_a)       v(door_b)       v(v_alarm)
0	0.000000e+00	4.999500e-04	4.999500e-04	1.110223e-15
1	1.000000e-08	4.999500e-04	4.999500e-04	1.110223e-15
2	2.000000e-08	4.999500e-04	4.999500e-04	1.110223e-15
3	4.000000e-08	4.999500e-04	4.999500e-04	1.110223e-15
4	8.000000e-08	4.999500e-04	4.999500e-04	1.110223e-15
5	1.600000e-07	4.999500e-04	4.999500e-04	1.110223e-15
6	3.200000e-07	4.999500e-04	4.999500e-04	1.110223e-15
7	6.400000e-07	4.999500e-04	4.999500e-04	1.110223e-15
8	1.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
9	2.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
10	3.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
11	4.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
12	5.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
13	6.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
14	7.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
15	8.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
16	9.280000e-06	4.999500e-04	4.999500e-04	1.110223e-15
17	1.028000e-05	4.999500e-04	4.999500e-04	1.110223e-15
18	1.128000e-05	4.999500e-04	4.999500e-04	1.110223e-15
19	1.228000e-05	4.999500e-04	4.999500e-04	1.110223e-15
20	1.328000e-05	4.999500e-04	4.999500e-04	1.110223e-15
21	1.428000e-05	4.999500e-04	4.999500e-04	1.110223e-15
22	1.528000e-05	4.999500e-04	4.999500e-04	1.110223e-15
23	1.628000e-05	4.999500e-04	4.999500e-04	1.110223e-15
... (1358 more rows) ...

Common mistakes and how to avoid them

  1. Leaving Inputs Floating: Failing to install R1 or R2 will cause the inputs to «float» when the switch is open (pressed). This leads to erratic LED behavior. Always use pull-down resistors with this switch configuration.
  2. Confusing NC vs NO Switches: If you use NO (Normally Open) switches with this specific wiring, the logic reverses (LED ON when doors are closed). Ensure you understand the mechanical state of the switch when the door is physically closed.
  3. Missing LED Resistor: Connecting the LED directly to the IC output (Pin 3) without R3 will damage the LED or the 74HC32 chip due to excessive current.

Troubleshooting

  • LED is always ON:
    • Check if S1 or S2 are wired incorrectly (e.g., shorting VCC to Input constantly).
    • Verify R1 and R2 are connected to Ground, not VCC.
    • Ensure the IC is a 74HC32 (OR) and not a 74HC00 (NAND) or similar.
  • LED never turns ON:
    • Check power supply connections to Pin 14 and Pin 7.
    • Ensure the LED polarity is correct (Anode to resistor, Cathode to GND).
    • Verify the switches are actually passing 5 V when released.
  • LED is dim:
    • The value of R3 might be too high (e.g., 10 kΩ instead of 330 Ω).
    • The power supply voltage might be below 3 V.

Possible improvements and extensions

  1. Audible Alarm: Connect a 5 V active buzzer in parallel with the LED (driven by a transistor if current exceeds 20 mA) to provide sound feedback.
  2. Interior Light Control: Add a delay circuit (using a capacitor and resistor or a 555 timer) so the light stays on for 10 seconds after the doors are closed, simulating a modern car courtesy light.

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: What is the primary objective of the circuit described in the text?




Question 2: Which specific logic gate IC is used in this project?




Question 3: What type of switches are used to simulate the door mechanics?




Question 4: What is the state of the LED when both doors are fully closed?




Question 5: What happens to the input signal when Door A is opened?




Question 6: What is the logic level of the inputs when both doors are closed?




Question 7: Why is this circuit useful for automotive safety?




Question 8: Besides automotive safety, what is another listed use case for this circuit?




Question 9: If both Door A and Door B are open, what is the status of the LED?




Question 10: What is the target audience level mentioned for this project?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:


Practical case: Lighting control from two points

Lighting control from two points prototype (Maker Style)

Level: Basic. Build a circuit where a pilot light can be activated from two independent switches using digital logic.

Objective and use case

In this project, you will build a digital control circuit using a 74HC32 OR gate to power an LED indicator when either of two push buttons is actuated. This demonstrates the fundamental logic function where an output is true if at least one input is true.

Why it is useful:
* Home Automation: Simulates a hallway light system where multiple switches can turn on a light.
* Security Systems: Represents an alarm trigger zone where any single sensor (door or window) triggers the siren.
* Automotive: Functions like interior dome lights that turn on if the driver’s side OR passenger’s side door is opened.
* Industrial Safety: Acts as an emergency stop system where pressing any button on a production line halts the machine.

Expected outcome:
* LED State: The LED remains OFF (Logic 0) only when both buttons are released.
* Single Press: Pressing Button A turns the LED ON (Logic 1).
* Single Press: Pressing Button B turns the LED ON (Logic 1).
* Simultaneous Press: Pressing both buttons keeps the LED ON (Logic 1).
* Target Audience: Students and hobbyists learning basic digital logic gates.

Materials

  • V1: 5 V DC supply
  • U1: 74HC32 (Quad 2-Input OR Gate IC)
  • S1: Momentary Push Button (NO – Normally Open), function: Input A
  • S2: Momentary Push Button (NO – Normally Open), function: Input B
  • R1: 10 kΩ resistor, function: Pull-down for Input A
  • R2: 10 kΩ resistor, function: Pull-down for Input B
  • R3: 330 Ω resistor, function: LED current limiting
  • D1: Red LED, function: Logic output indicator

Pin-out of the IC used

Chip: 74HC32 (Quad 2-Input OR Gate)

Pin Name Logic Function Connection in this case
1 1A Input A Connected to S1 and R1
2 1B Input B Connected to S2 and R2
3 1Y Output Connected to R3 (LED driver)
7 GND Ground Connected to 0V
14 VCC Power Supply Connected to +5V

Wiring guide

This guide defines the connections using specific node names to ensure a clean circuit assembly.

  • Power Nodes:

    • VCC: Connect positive terminal of V1 to U1 Pin 14.
    • 0 (GND): Connect negative terminal of V1 to U1 Pin 7.
  • Input A Logic (NODE_A):

    • Connect S1 between VCC and NODE_A.
    • Connect R1 between NODE_A and 0 (GND).
    • Connect U1 Pin 1 to NODE_A.
  • Input B Logic (NODE_B):

    • Connect S2 between VCC and NODE_B.
    • Connect R2 between NODE_B and 0 (GND).
    • Connect U1 Pin 2 to NODE_B.
  • Output Logic (NODE_Y):

    • Connect U1 Pin 3 to one end of R3.
    • Connect the other end of R3 to the anode (long leg) of D1.
    • Connect the cathode (short leg) of D1 to 0 (GND).

Conceptual block diagram

Conceptual block diagram — 74HC32 OR gate

Schematic

[ INPUTS ]                                  [ LOGIC ]                                [ OUTPUT ]

[ VCC ]--> [ S1 (NO) ] --+--(NODE_A)----------->+-------------+
                         |  (Pin 1)             |             |
                    [ R1 (10k) ]                |  U1: 74HC32 |
                         v                      |  (OR Gate)  |--(NODE_Y)--> [ R3 (330) ] --> [ D1 (LED) ] --> [ GND ]
                      [ GND ]                   |  (Pin 3)    |
                                                |             |
[ VCC ]--> [ S2 (NO) ] --+--(NODE_B)----------->+-------------+
                         |  (Pin 2)
                    [ R2 (10k) ]
                         v
                      [ GND ]
Schematic (ASCII)

Electrical diagram

Electrical diagram for case: Practical case: Lighting control from two points
Generated from the validated SPICE netlist for this case.

🔒 This electrical diagram is premium. With the monthly membership (7-day free trial) you can unlock the complete didactic material and the print-ready PDF pack.🔓 See premium access plans

Truth table

The 74HC32 follows the standard OR logic table:

Input A (S1) Input B (S2) Output Y (LED) State Description
0 (Released) 0 (Released) 0 (OFF) No active signal
0 (Released) 1 (Pressed) 1 (ON) Activated by B
1 (Pressed) 0 (Released) 1 (ON) Activated by A
1 (Pressed) 1 (Pressed) 1 (ON) Activated by both

Measurements and tests

  1. Idle Check: Before pressing anything, measure the voltage at NODE_A and NODE_B relative to GND. It should be close to 0V (Logic 0) due to the pull-down resistors. The LED should be off.
  2. Input A Test: Press S1. Measure voltage at NODE_A; it should rise to 5V. Verify D1 lights up.
  3. Input B Test: Press S2. Measure voltage at NODE_B; it should rise to 5V. Verify D1 lights up.
  4. Combined Test: Press both buttons simultaneously. The LED should remain lit without flickering.

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Practical case: Lighting control from two points

* --- Power Supply ---
* V1: 5V DC Supply connected to VCC and GND (0)
V1 VCC 0 DC 5

* --- Input A ---
* S1: Momentary Push Button (NO)
* Modeled as a voltage-controlled switch (S1) driven by a pulse source (V_ACT_A)
* to simulate the physical user action of pressing the button.
V_ACT_A ACT_A 0 PULSE(0 5 50u 1u 1u 100u 200u)
S1 VCC NODE_A ACT_A 0 SW_BTN

* R1: 10k Pull-down resistor for Input A
R1 NODE_A 0 10k

* --- Input B ---
* S2: Momentary Push Button (NO)
* Modeled as a voltage-controlled switch (S2) driven by a pulse source (V_ACT_B)
V_ACT_B ACT_B 0 PULSE(0 5 50u 1u 1u 200u 400u)
S2 VCC NODE_B ACT_B 0 SW_BTN

* R2: 10k Pull-down resistor for Input B
R2 NODE_B 0 10k

* --- Logic IC U1: 74HC32 (Quad 2-Input OR Gate) ---
* Wiring Guide: Pin 1 to NODE_A, Pin 2 to NODE_B, Pin 3 to NODE_Y
* Pin 7 to GND (0), Pin 14 to VCC
XU1 NODE_A NODE_B NODE_Y 0 VCC 74HC32

* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

🔒 Part of this section is premium. With the monthly membership (7-day free trial) you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* Practical case: Lighting control from two points

* --- Power Supply ---
* V1: 5V DC Supply connected to VCC and GND (0)
V1 VCC 0 DC 5

* --- Input A ---
* S1: Momentary Push Button (NO)
* Modeled as a voltage-controlled switch (S1) driven by a pulse source (V_ACT_A)
* to simulate the physical user action of pressing the button.
V_ACT_A ACT_A 0 PULSE(0 5 50u 1u 1u 100u 200u)
S1 VCC NODE_A ACT_A 0 SW_BTN

* R1: 10k Pull-down resistor for Input A
R1 NODE_A 0 10k

* --- Input B ---
* S2: Momentary Push Button (NO)
* Modeled as a voltage-controlled switch (S2) driven by a pulse source (V_ACT_B)
V_ACT_B ACT_B 0 PULSE(0 5 50u 1u 1u 200u 400u)
S2 VCC NODE_B ACT_B 0 SW_BTN

* R2: 10k Pull-down resistor for Input B
R2 NODE_B 0 10k

* --- Logic IC U1: 74HC32 (Quad 2-Input OR Gate) ---
* Wiring Guide: Pin 1 to NODE_A, Pin 2 to NODE_B, Pin 3 to NODE_Y
* Pin 7 to GND (0), Pin 14 to VCC
XU1 NODE_A NODE_B NODE_Y 0 VCC 74HC32

* --- Output Stage ---
* R3: 330 Ohm LED current limiting resistor
R3 NODE_Y NODE_LED 330

* D1: Red LED Logic output indicator
D1 NODE_LED 0 LED_RED

* --- Models and Subcircuits ---

* Switch Model (Normally Open)
* Vt=2.5V: Threshold voltage for switching
* Ron=0.1: Low resistance when closed
* Roff=10Meg: High resistance when open
.model SW_BTN SW(Vt=2.5 Ron=0.1 Roff=10Meg)

* LED Model (Generic Red LED)
.model LED_RED D(IS=1e-22 N=1.5 RS=5 BV=5 IBV=10u CJO=10p)

* 74HC32 Behavioral Subcircuit
* Implements robust continuous logic to avoid convergence issues
.subckt 74HC32 1 2 3 7 14
* Pin Definitions: 1=InputA, 2=InputB, 3=OutputY, 7=GND, 14=VCC
* Logic: Y = A OR B
* Implemented using Sigmoid function S(x) = 1 / (1 + exp(-k*(x-threshold)))
* OR(A,B) is equivalent to 1 - (NOT_A * NOT_B)
* V(14) scales the output to the supply rail
B_OR 3 7 V = V(14) * (1 - ( (1/(1+exp(-20*(V(1)-2.5)))) * (1/(1+exp(-20*(V(2)-2.5)))) ))
.ends

* --- Simulation Directives ---
* Transient analysis for 600us to capture all logic states of the pulses
.tran 1u 600u

* Print required voltages for analysis
.print tran V(NODE_A) V(NODE_B) V(NODE_Y) V(NODE_LED)

* Calculate DC operating point
.op

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (1562 rows)
Index   time            v(node_a)       v(node_b)       v(node_y)
0	0.000000e+00	4.995005e-03	4.995005e-03	5.000000e+00
1	1.000000e-08	4.995005e-03	4.995005e-03	5.000000e+00
2	2.000000e-08	4.995005e-03	4.995005e-03	5.000000e+00
3	4.000000e-08	4.995005e-03	4.995005e-03	5.000000e+00
4	8.000000e-08	4.995005e-03	4.995005e-03	5.000000e+00
5	1.600000e-07	4.995005e-03	4.995005e-03	5.000000e+00
6	3.200000e-07	4.995005e-03	4.995005e-03	5.000000e+00
7	6.400000e-07	4.995005e-03	4.995005e-03	5.000000e+00
8	1.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
9	2.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
10	3.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
11	4.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
12	5.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
13	6.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
14	7.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
15	8.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
16	9.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
17	1.028000e-05	4.995005e-03	4.995005e-03	5.000000e+00
18	1.128000e-05	4.995005e-03	4.995005e-03	5.000000e+00
19	1.228000e-05	4.995005e-03	4.995005e-03	5.000000e+00
20	1.328000e-05	4.995005e-03	4.995005e-03	5.000000e+00
21	1.428000e-05	4.995005e-03	4.995005e-03	5.000000e+00
22	1.528000e-05	4.995005e-03	4.995005e-03	5.000000e+00
23	1.628000e-05	4.995005e-03	4.995005e-03	5.000000e+00
... (1538 more rows) ...


Reference SPICE netlist (ngspice)

* Practical case: Lighting control from two points

* --- Power Supply ---
* V1: 5V DC Supply connected to VCC and GND (0)
V1 VCC 0 DC 5

* --- Input A ---
* S1: Momentary Push Button (NO)
* Modeled as a voltage-controlled switch (S1) driven by a pulse source (V_ACT_A)
* to simulate the physical user action of pressing the button.
V_ACT_A ACT_A 0 PULSE(0 5 50u 1u 1u 100u 200u)
S1 VCC NODE_A ACT_A 0 SW_BTN

* R1: 10k Pull-down resistor for Input A
R1 NODE_A 0 10k

* --- Input B ---
* S2: Momentary Push Button (NO)
* Modeled as a voltage-controlled switch (S2) driven by a pulse source (V_ACT_B)
V_ACT_B ACT_B 0 PULSE(0 5 50u 1u 1u 200u 400u)
S2 VCC NODE_B ACT_B 0 SW_BTN

* R2: 10k Pull-down resistor for Input B
R2 NODE_B 0 10k

* --- Logic IC U1: 74HC32 (Quad 2-Input OR Gate) ---
* Wiring Guide: Pin 1 to NODE_A, Pin 2 to NODE_B, Pin 3 to NODE_Y
* Pin 7 to GND (0), Pin 14 to VCC
XU1 NODE_A NODE_B NODE_Y 0 VCC 74HC32

* --- Output Stage ---
* R3: 330 Ohm LED current limiting resistor
R3 NODE_Y NODE_LED 330

* D1: Red LED Logic output indicator
D1 NODE_LED 0 LED_RED

* --- Models and Subcircuits ---

* Switch Model (Normally Open)
* Vt=2.5V: Threshold voltage for switching
* Ron=0.1: Low resistance when closed
* Roff=10Meg: High resistance when open
.model SW_BTN SW(Vt=2.5 Ron=0.1 Roff=10Meg)

* LED Model (Generic Red LED)
.model LED_RED D(IS=1e-22 N=1.5 RS=5 BV=5 IBV=10u CJO=10p)

* 74HC32 Behavioral Subcircuit
* Implements robust continuous logic to avoid convergence issues
.subckt 74HC32 1 2 3 7 14
* Pin Definitions: 1=InputA, 2=InputB, 3=OutputY, 7=GND, 14=VCC
* Logic: Y = A OR B
* Implemented using Sigmoid function S(x) = 1 / (1 + exp(-k*(x-threshold)))
* OR(A,B) is equivalent to 1 - (NOT_A * NOT_B)
* V(14) scales the output to the supply rail
B_OR 3 7 V = V(14) * (1 - ( (1/(1+exp(-20*(V(1)-2.5)))) * (1/(1+exp(-20*(V(2)-2.5)))) ))
.ends

* --- Simulation Directives ---
* Transient analysis for 600us to capture all logic states of the pulses
.tran 1u 600u

* Print required voltages for analysis
.print tran V(NODE_A) V(NODE_B) V(NODE_Y) V(NODE_LED)

* Calculate DC operating point
.op

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)

Common mistakes and how to avoid them

  1. Leaving Inputs Floating: Failing to install pull-down resistors (R1, R2) causes the inputs to «float,» often leading to the LED flickering or staying on permanently due to static noise. Always tie unused inputs to GND or VCC.
  2. Missing Power to Chip: Forgetting to connect Pin 14 to +5V and Pin 7 to GND. The logic gates inside the chip cannot function without power.
  3. LED Orientation: Inserting the LED backwards (anode to ground). The LED will act as an open circuit and will never turn on.

Troubleshooting

  • LED is always ON:
    • Check if R1 or R2 is missing or disconnected.
    • Verify you are using a Normally Open (NO) button, not a Normally Closed (NC) one.
  • LED does not turn ON when buttons are pressed:
    • Check U1 power connections (Pins 7 and 14).
    • Ensure the LED is oriented correctly (Flat side/short leg to GND).
  • LED is very dim:
    • R3 value might be too high (e.g., using 10 kΩ instead of 330 Ω).
    • Supply voltage V1 might be too low.

Possible improvements and extensions

  1. Three-Point Control: Cascade a second OR gate (using the remaining gates on the 74HC32 chip) to add a third switch, allowing control from three locations.
  2. Latch Circuit: Add a feedback loop or use an SR latch so that pressing a button once turns the light on and keeps it on until a «Reset» button is pressed (simulating an alarm memory).

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: What is the primary objective of the circuit described in the project?




Question 2: Which specific logic gate IC is used in this project?




Question 3: What is the state of the LED when both buttons are released?




Question 4: How does the circuit behave if both Button A and Button B are pressed simultaneously?




Question 5: Which automotive application is cited as an example of this logic function?




Question 6: In an industrial safety context, how is this logic applied?




Question 7: What fundamental logic function does this circuit demonstrate?




Question 8: How does this circuit relate to home automation?




Question 9: What happens to the LED if only Button A is pressed?




Question 10: Which security system application is mentioned for this circuit?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:


Practical case: Dual Sensor Alarm System

Dual Sensor Alarm System prototype (Maker Style)

Level: Basic — Implement a logic circuit that triggers an alarm if either of two sensors detects an intrusion.

Objective and use case

In this practical case, you will build a digital logic circuit using a 74HC32 (OR gate) integrated circuit. The circuit monitors two switches representing door sensors; if either switch is activated (logic HIGH), the output LED (alarm) turns on.

Why it is useful:
* Home Security: Simulates a system where opening either the front door or the back door triggers the siren.
* Automotive Safety: Functions like the dashboard «door open» light, which illuminates if any passenger door is not fully closed.
* Industrial Controls: Acts as a simplified fault monitor where multiple error signals can trigger a single warning light.

Expected outcome:
* Standby State: When both switches are open (0 V input), the LED remains OFF.
* Active State 1: When Switch A is closed (5 V input), the LED turns ON.
* Active State 2: When Switch B is closed (5 V input), the LED turns ON.
* Dual Active State: When both switches are closed, the LED remains ON.
* Target Audience: Electronics students and hobbyists learning basic digital logic gates.

Materials

  • V1: 5 V DC power supply or battery pack
  • U1: 74HC32 Quad 2-input OR gate IC
  • S1: SPST toggle switch or push-button, function: Front Door Sensor (Input A)
  • S2: SPST toggle switch or push-button, function: Back Door Sensor (Input B)
  • R1: 10 kΩ resistor, function: pull-down for Input A
  • R2: 10 kΩ resistor, function: pull-down for Input B
  • R3: 330 Ω resistor, function: LED current limiting
  • D1: Red LED, function: Alarm indicator
  • Breadboard and hook-up wires

Pin-out of the IC used

Selected Chip: 74HC32 (Quad 2-input OR gate)

Pin Name Logic function Connection in this case
1 1A Input A (Gate 1) Connected to S1 and R1
2 1B Input B (Gate 1) Connected to S2 and R2
3 1Y Output (Gate 1) Connected to R3 (LED driver)
7 GND Ground Connected to 0 (Negative rail)
14 VCC Positive Supply Connected to 5 V rail

Wiring guide

Construct the circuit on the breadboard following these connections. The node names (e.g., IN_A, VCC) indicate electrical junctions.

  • Power Supply:
    • V1: Positive terminal to node VCC.
    • V1: Negative terminal to node 0 (GND).
  • IC Power:
    • U1 (Pin 14): Connect to VCC.
    • U1 (Pin 7): Connect to 0.
  • Sensor A (Front Door):
    • S1: Connect between VCC and node IN_A.
    • R1: Connect between node IN_A and 0 (Functions as a pull-down resistor to ensure logic 0 when switch is open).
    • U1 (Pin 1): Connect to node IN_A.
  • Sensor B (Back Door):
    • S2: Connect between VCC and node IN_B.
    • R2: Connect between node IN_B and 0 (Functions as a pull-down resistor).
    • U1 (Pin 2): Connect to node IN_B.
  • Output Stage:
    • U1 (Pin 3): Connect to node SIG_OUT.
    • R3: Connect between node SIG_OUT and node LED_ANODE.
    • D1: Anode to node LED_ANODE, Cathode to 0.

Conceptual block diagram

Conceptual block diagram — 74HC32 OR gate

Schematic

[ INPUT SENSORS ]                        [ LOGIC PROCESSING ]                  [ OUTPUT ALARM ]

[ VCC ] --> [ S1: Front Door ] --+--(IN_A)--> [ Pin 1 ] --+
                                 |                        |
                           [ R1: 10k ]                    |
                                 |                        v
                               [ GND ]             +-------------+
                                                   |  U1: 74HC32 |
                                                   |  (OR Gate)  | --(Pin 3)--> [ R3: 330 ] --> [ D1: LED ] --> GND
                                                   +-------------+
                               [ GND ]                    ^
                                 |                        |
                           [ R2: 10k ]                    |
                                 |                        |
[ VCC ] --> [ S2: Back Door  ] --+--(IN_B)--> [ Pin 2 ] --+
Schematic (ASCII)

Electrical diagram

Electrical diagram for case: Practical case: Dual Sensor Alarm System
Generated from the validated SPICE netlist for this case.

🔒 This electrical diagram is premium. With the monthly membership (7-day free trial) you can unlock the complete didactic material and the print-ready PDF pack.🔓 See premium access plans

Truth table

The 74HC32 behaves according to the standard OR logic:

Sensor A (S1) Sensor B (S2) Pin 1 (Volts) Pin 2 (Volts) Output Pin 3 (Volts) LED State
Open Open 0 V 0 V 0 V (LOW) OFF
Open Closed 0 V 5 V 5 V (HIGH) ON
Closed Open 5 V 0 V 5 V (HIGH) ON
Closed Closed 5 V 5 V 5 V (HIGH) ON

Measurements and tests

  1. Supply Check: Before inserting the IC, power up the rails and measure the voltage between VCC and 0. It should read approximately 5 V.
  2. Input Verification:
    • Keep U1 inserted. Measure voltage at Pin 1 relative to GND. It should be 0 V.
    • Press S1. The voltage at Pin 1 should jump to ~5 V.
    • Repeat for S2 and Pin 2.
  3. Logic Logic Test:
    • Ensure both switches are open. Measure Pin 3 (Output); it should be close to 0 V.
    • Close S1 only. Measure Pin 3; it should be close to 5 V. The LED should light up.
    • Close S2 only. Measure Pin 3; it should be close to 5 V. The LED should light up.

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Practical case: Dual Sensor Alarm System
* Corrected SPICE Netlist based on BOM and Wiring Guide

* ==============================================================================
* POWER SUPPLY
* ==============================================================================
* V1: 5V DC Supply
* Wiring: Positive to VCC, Negative to 0 (GND)
V1 VCC 0 DC 5

* ==============================================================================
* INPUT SENSORS
* ==============================================================================
* Sensor A: Front Door (S1, R1)
* Wiring: S1 connects VCC to IN_A. R1 connects IN_A to 0 (Pull-down).
* Simulation: S1 is modeled as a voltage-controlled switch driven by a control pulse
* to simulate a button press sequence.
V_CTRL_A CTRL_A 0 PULSE(0 5 10u 1u 1u 100u 200u)
S1 VCC IN_A CTRL_A 0 SW_GEN
R1 IN_A 0 10k

* Sensor B: Back Door (S2, R2)
* Wiring: S2 connects VCC to IN_B. R2 connects IN_B to 0 (Pull-down).
* Simulation: S2 control pulse is offset to test all truth table combinations.
V_CTRL_B CTRL_B 0 PULSE(0 5 10u 1u 1u 200u 400u)
S2 VCC IN_B CTRL_B 0 SW_GEN
R2 IN_B 0 10k

* ==============================================================================
* LOGIC IC: U1 (74HC32)
* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

🔒 Part of this section is premium. With the monthly membership (7-day free trial) you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* Practical case: Dual Sensor Alarm System
* Corrected SPICE Netlist based on BOM and Wiring Guide

* ==============================================================================
* POWER SUPPLY
* ==============================================================================
* V1: 5V DC Supply
* Wiring: Positive to VCC, Negative to 0 (GND)
V1 VCC 0 DC 5

* ==============================================================================
* INPUT SENSORS
* ==============================================================================
* Sensor A: Front Door (S1, R1)
* Wiring: S1 connects VCC to IN_A. R1 connects IN_A to 0 (Pull-down).
* Simulation: S1 is modeled as a voltage-controlled switch driven by a control pulse
* to simulate a button press sequence.
V_CTRL_A CTRL_A 0 PULSE(0 5 10u 1u 1u 100u 200u)
S1 VCC IN_A CTRL_A 0 SW_GEN
R1 IN_A 0 10k

* Sensor B: Back Door (S2, R2)
* Wiring: S2 connects VCC to IN_B. R2 connects IN_B to 0 (Pull-down).
* Simulation: S2 control pulse is offset to test all truth table combinations.
V_CTRL_B CTRL_B 0 PULSE(0 5 10u 1u 1u 200u 400u)
S2 VCC IN_B CTRL_B 0 SW_GEN
R2 IN_B 0 10k

* ==============================================================================
* LOGIC IC: U1 (74HC32)
* ==============================================================================
* Wiring: Pin 1=IN_A, Pin 2=IN_B, Pin 3=SIG_OUT, Pin 7=0, Pin 14=VCC
* Uses a subcircuit to model the OR gate logic
XU1 IN_A IN_B SIG_OUT 0 VCC 74HC32

* ==============================================================================
* OUTPUT STAGE
* ==============================================================================
* Wiring: SIG_OUT -> R3 -> LED_ANODE -> D1 -> 0
R3 SIG_OUT LED_ANODE 330
D1 LED_ANODE 0 LED_RED

* ==============================================================================
* MODELS & SUBCIRCUITS
* ==============================================================================

* Model for Switch (Idealized Push-Button)
.model SW_GEN SW(Vt=2.5 Ron=0.1 Roff=10Meg)

* Model for Red LED
.model LED_RED D(IS=1u N=3 RS=5)

* Subcircuit for 74HC32 (Quad 2-Input OR Gate)
* Implements OR logic: Y = A OR B
* Mathematical implementation using De Morgan's Law for continuous signals:
* Y = 1 - ( (1-A) * (1-B) )  (normalized 0-1 logic)
.subckt 74HC32 A B Y GND_PIN VCC_PIN
    * Sigmoid function to normalize inputs: 1/(1+exp(-20*(V(in)-2.5)))
    * Logic formula: V(Y) = V(VCC) * (1 - ( (1-Sig(A)) * (1-Sig(B)) ))
    B_OR Y GND_PIN V = V(VCC_PIN) * (1 - ( (1 - 1/(1+exp(-20*(V(A)-2.5)))) * (1 - 1/(1+exp(-20*(V(B)-2.5)))) ))
.ends

* ==============================================================================
* ANALYSIS
* ==============================================================================
* Transient analysis to verify truth table (00, 10, 01, 11)
.tran 1u 500u

* Monitor Input and Output Voltages
.print tran V(IN_A) V(IN_B) V(SIG_OUT) V(LED_ANODE)

* Compute DC Operating Point
.op

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (1202 rows)
Index   time            v(in_a)         v(in_b)         v(sig_out)
0	0.000000e+00	4.995005e-03	4.995005e-03	5.000000e+00
1	1.000000e-08	4.995005e-03	4.995005e-03	5.000000e+00
2	2.000000e-08	4.995005e-03	4.995005e-03	5.000000e+00
3	4.000000e-08	4.995005e-03	4.995005e-03	5.000000e+00
4	8.000000e-08	4.995005e-03	4.995005e-03	5.000000e+00
5	1.600000e-07	4.995005e-03	4.995005e-03	5.000000e+00
6	3.200000e-07	4.995005e-03	4.995005e-03	5.000000e+00
7	6.400000e-07	4.995005e-03	4.995005e-03	5.000000e+00
8	1.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
9	2.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
10	3.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
11	4.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
12	5.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
13	6.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
14	7.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
15	8.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
16	9.280000e-06	4.995005e-03	4.995005e-03	5.000000e+00
17	1.000000e-05	4.995005e-03	4.995005e-03	5.000000e+00
18	1.010000e-05	4.995005e-03	4.995005e-03	5.000000e+00
19	1.026000e-05	4.995005e-03	4.995005e-03	5.000000e+00
20	1.030750e-05	4.995005e-03	4.995005e-03	5.000000e+00
21	1.039062e-05	4.995005e-03	4.995005e-03	5.000000e+00
22	1.041363e-05	4.995005e-03	4.995005e-03	5.000000e+00
23	1.045390e-05	4.995005e-03	4.995005e-03	5.000000e+00
... (1178 more rows) ...

Common mistakes and how to avoid them

  1. Floating Inputs: Forgetting R1 or R2 (pull-down resistors).
    • Solution: Logic gates behave unpredictably if inputs are not connected to a definite voltage. Always use pull-down resistors (to ground) or pull-up resistors (to VCC) for mechanical switches.
  2. Missing LED Resistor: Connecting the LED directly to the IC output.
    • Solution: Always include R3 (330 Ω) to limit current. Without it, you may damage the LED or the 74HC32 output stage.
  3. Incorrect IC Orientation: Inserting the 74HC32 backwards.
    • Solution: Locate the notch or dot on the IC package. The notch indicates the end with Pin 1 and Pin 14.

Troubleshooting

  • LED is always ON:
    • Check if R1 or R2 is disconnected (floating inputs often drift HIGH).
    • Verify S1 or S2 are not wired as «normally closed» by mistake.
    • Check for short circuits between VCC and Pin 1/Pin 2.
  • LED never turns ON:
    • Check if the IC is powered (Pin 14 at 5V, Pin 7 at GND).
    • Verify LED polarity (Anode must face the resistor/IC, Cathode to GND).
  • LED is very dim:
    • The value of R3 might be too high (e.g., using 10 kΩ instead of 330 Ω).
    • Power supply voltage might be too low (< 3 V).

Possible improvements and extensions

  1. Latched Alarm: Add a flip-flop or create a latch circuit so the alarm stays ON even after the intruder closes the door (S1/S2 open again), requiring a manual reset.
  2. Audible Alert: Connect an active buzzer in parallel with the LED (driven by a transistor if the current requirement exceeds 20mA) to add sound to the visual alarm.

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: Which integrated circuit is specified in the text to build the logic circuit?




Question 2: What specific logic function does the 74HC32 IC perform in this circuit?




Question 3: According to the expected outcome, what is the state of the LED when both switches are open (0 V input)?




Question 4: What is the function of the 10 kΩ resistors (R1 and R2) typically found in this type of circuit setup?




Question 5: If Switch A is closed (5 V input) and Switch B is open, what happens to the LED?




Question 6: Which of the following is listed as a real-world use case for this circuit?




Question 7: What is the primary purpose of the 330 Ω resistor (R3) connected to the output?




Question 8: What is the expected outcome if both Switch A and Switch B are closed simultaneously?




Question 9: Based on the input levels mentioned (5 V input), what is the appropriate power supply voltage for this circuit?




Question 10: Who is explicitly mentioned as the target audience for this practical case?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me: