Tamil Nadu HSE First Year Computer Science study materials
Tamil Nadu HSE First Year Computer Science study resources

Corridor Two-Way Light and Lab Safety Buzzer

Tamil Nadu HSE First Year Computer Science · Put your knowledge to work in context.

All case studies

Corridor Two-Way Light and Lab Safety Buzzer

A school has added a corridor with a light bulb that must be controlled from switches at both ends: changing either switch should change the bulb state, while leaving both switches alone should leave the state unchanged. The electrician has only a box of 7400 ICs. Each 7400 IC contains four independent 2-input NAND gates, and no AND, OR, NOT, or XOR ICs are available. He has five 7400 ICs in total. In the same building, a science lab needs a safety buzzer. The buzzer must sound when the main lab switch M is ON and either the door sensor D is open or the gas sensor G is high. Before wiring anything, the electrician asks you to derive the logic expressions, convert them to NAND-only form, and count how many ICs the two jobs will consume.

1. Construct the truth table for the two-way corridor light and derive its Boolean expression. Explain why an AND gate or an OR gate cannot be used directly.

Read the worked answer

Let the switches be A and B, with 1 meaning 'up' and 0 meaning 'down', and let Y be the bulb. With two switches there are four input combinations. The bulb must be ON when exactly one switch is up: (0,1) and (1,0). It must be OFF for (0,0) and (1,1). The truth table is therefore 00→0, 01→1, 10→1, 11→0. The canonical expression is Y = A'B + AB', which is the XOR function. An AND gate gives 1 only for 11, so it would light the bulb only when both switches are up. An OR gate gives 1 for 01, 10 and 11, so the bulb would stay on when both switches are up and could not be turned off from either end. The circuit needs inequality detection, which is exactly what XOR provides.

2. Implement the corridor light using only 2-input NAND gates. Draw the gate connections in words, count the gates used, and state how many 7400 ICs are needed and whether any gates remain spare.

Read the worked answer

XOR can be built from four NAND gates. Let N1 = A NAND B. Then N2 = A NAND N1 and N3 = B NAND N1. Finally N4 = N2 NAND N3, and N4 is A'B + AB'. Check the case A=0, B=1: N1 = 1, N2 = 1, N3 = 0, so N4 = 1. For A=1, B=1: N1 = 0, N2 = 1, N3 = 1, so N4 = 0. For A=0, B=0: N1 = 1, N2 = 1, N3 = 1, so N4 = 0. The circuit uses four NAND gates, which is exactly one 7400 IC. That IC has no spare gates, so the corridor light alone consumes one complete IC.

3. For the lab buzzer, write the Boolean expression for B in terms of M, D and G, convert it to NAND-only form, and calculate the total number of 7400 ICs needed for both the corridor light and the buzzer.

Read the worked answer

The buzzer condition is 'main switch ON AND (door open OR gas high)', so B = M · (D + G) = MD + MG. Using NAND: D' = D NAND D (1 gate), G' = G NAND G (1 gate), and D + G = D' NAND G' (1 gate). Then M · (D + G) is obtained by NANDing M with (D + G), giving the inverted product, followed by a NAND inverter: N4 = M NAND (D+G), B = N4 NAND N4. That is five NAND gates. The corridor light used four, so the total is nine gates. Each 7400 supplies four gates, so 9 ÷ 4 requires three ICs, giving 12 gates and three spare gates. One IC cannot be shared between the two jobs if they are wired in different rooms, so in practice the electrician should keep the spare gates available for later repairs.