Projects / Two-way staircase switch

Two-way staircase switch

Beginner2 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. MICROUSB

    Power the board

    USB breakout to the breadboard rails.

  2. Place the chip

    Check pin 1 and the notch.

  3. Power the chip

    Pin 14 to 5 V, pin 7 to ground, add the 100 nanofarad.

  4. Tie the unused inputs

    Pins 4, 5, 9, 10, 12, 13 to ground.

  5. Wire the switches

    Commons to pins 1 and 2, outer terminals to 5 V and ground.

  6. 17.1 mA

    Wire the lamp

    Pin 3, 1 kilohm, LED to ground.

  7. Test all four settings

    Compare with the truth table.

  8. Add a second stage

    Pin 6 could drive a second lamp.

In short

How do you build a two-way staircase switch?

Two toggle switches and an XOR gate make a lamp that either switch can turn on or off, like a staircase light. You need Toggle switch SPDT (MTS-102) × 2, 74HC86 quad XOR gate, LED 5 mm red, Resistor 1 kΩ, Ceramic Capacitor 100 nF, Micro USB breakout board, 5 V 2 A USB adapter, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points. It takes 8 steps and about 120 minutes.

Level
Beginner
Time
About 120 min
Parts
9

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
USB breakout VBUSBreadboard positive rail5 V from the adapter
USB breakout GNDBreadboard negative railGround
74HC86 pin 14 (VCC)Positive railChip power
74HC86 pin 7 (GND)Negative railChip ground
Toggle 1 middle terminal74HC86 pin 1 (A1)Switch 1 level goes to input A
Toggle 2 middle terminal74HC86 pin 2 (B1)Switch 2 level goes to input B
Each toggle outer terminalsOne to the positive rail, one to groundInput is always high or low, never floating
74HC86 pin 3 (Y1)1 kilohm resistor, red LED anodeLamp output
Red LED cathodeNegative railReturn
74HC86 pins 4, 5, 9, 10, 12, 13Negative railUnused gate inputs tied to ground
100 nanofarad capacitorBetween pin 14 and pin 7Decoupling close to the chip

Code

The XOR gate is the heart of a two-way switch. Its output is high only when its two inputs are different, so changing either input flips the output. This is exactly what a staircase light does: one switch at the bottom and one at the top, and either can turn the lamp on or off regardless of the other. Each toggle switch is wired so its middle terminal goes to a gate input and its outer terminals go to 5 volts and ground, which means the input is always a firm high or low and never floats. A floating CMOS input is a classic cause of strange behaviour, because it picks up noise and can draw extra current. The same rule applies to the unused gates on the chip: tie their inputs to ground. A small 100 nanofarad capacitor across the supply pins smooths the sharp current spikes the chip draws when it switches. The LED uses a 1 kilohm resistor, since 74HC outputs are designed for a few milliamps, and the 330 ohm often seen in LED circuits would ask too much. Draw the truth table first and check all four switch combinations against it.

Build notes (no code needed for this build)

Pinout of the 74HC86 (14-pin DIP, notch at the top, pin 1 at the top left):
  1 A1, 2 B1, 3 Y1, 4 A2, 5 B2, 6 Y2, 7 GND, 8 Y3, 9 A3, 10 B3, 11 Y4, 12 A4, 13 B4, 14 VCC.

Truth table for an XOR gate (Y = A xor B): the output is high only when the two inputs are DIFFERENT.
  Switch 1   Switch 2   Lamp
  down       down       off
  down       up         on
  up         down       on
  up         up         off
Flipping either switch changes the lamp, which is exactly how a two-way staircase light works.

Switch wiring: a toggle switch (SPDT) has three terminals. The middle one is the common. Connect one outer terminal to 5 V and the other to ground, so the common is always at a clear high or low level. If an input is left unconnected, a CMOS input can float and give random results.

LED current: the HC output has a drive limit of about 4 mA for good logic levels. With 1 kilohm the LED draws about (5 - 2.0) / 1000 = 3 mA, which is bright enough on a modern LED and safe for the chip. Do not use 220 ohm.

Unused gates: tie every unused input to ground. Floating CMOS inputs draw extra current and can oscillate.

Power: the micro-USB breakout board gives 5 V from the adapter. Only connect the VBUS and GND pads, leave the data pads unused.

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Both switches downLamp off
One switch upLamp on
Both switches upLamp off
Flip either switchLamp always changes
Voltage at pin 3About 5 V when on, 0 V when off

If it does not work

Lamp always off

Check the chip is powered on pins 14 and 7.

Lamp flickers

An input is floating, check the switch outer terminals.

Lamp dim

1 kilohm is right, check the LED direction.

Chip warm

Check the supply polarity at the USB breakout.

Works with only one switch

The second switch common is not on pin 2.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the two-way staircase switch?

Toggle switch SPDT (MTS-102) × 2, 74HC86 quad XOR gate, LED 5 mm red, Resistor 1 kΩ, Ceramic Capacitor 100 nF, Micro USB breakout board, 5 V 2 A USB adapter, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points.

How long does the two-way staircase switch take to build?

About 120 minutes for a beginner maker, in 8 steps.

How do I know the two-way staircase switch works?

Both switches down: Lamp off. One switch up: Lamp on. Both switches up: Lamp off.

Lamp always off: what should I check?

Check the chip is powered on pins 14 and 7.

Lamp flickers: what should I check?

An input is floating, check the switch outer terminals.

Lamp dim: what should I check?

1 kilohm is right, check the LED direction.

Chip warm: what should I check?

Check the supply polarity at the USB breakout.