DIP switch (4 and 8 way)
A row of tiny slide switches in the body of a chip.
It sits across the breadboard's center channel like a DIP IC, and each switch joins the pin under it on one side to the pin straight across on the other. Set once by hand and left, which is what they are for: addresses, options, and the bits of a number. Aliases: DIP switch, DIL switch, piano switch, 4-position switch, 8-position switch, SPST array.
Pins
| Pin | What it does |
|---|---|
1A to 8A |
One side of switches 1 to 8, along the bottom row. |
1B to 8B |
The other side, along the top row, each straight across from its A pin. |
The four-way switch has 1A to 4A and 1B to 4B. Switch n connects nA to nB
when it is on, and nothing else: no two switches share a pin.
Truth table
| Lever | nA to nB |
|---|---|
| Up, towards ON | Connected (a closed switch) |
| Down | Open, both pins high impedance |
Properties
| Property | What it does |
|---|---|
on |
Where the switches start, as a number: bit 0 is switch 1. 5 means switches 1 and 3 are on. |
While it runs
Click a lever to flip that switch. With the simulation stopped, a click changes the
on property instead, so the circuit is saved with the switches where you left them.
How to wire it
Exactly like a pushbutton: one side of every switch to a common rail, the other side
to an input with a pull resistor. With the A side on ground and a 10 k pull-up on
each B side, an on switch reads 0 and an off switch reads 1; with the A side on
5 V and pull-downs, on reads 1. A resistor network in the row
beside the switch is eight pull resistors in one part, and leaves each strip a hole
for its wire.
What the model gets right
A closed switch is a real contact (a fraction of an ohm) that passes current either way, so a DIP switch can route a supply as well as set a logic level, and an open switch leaves both of its pins floating, as on the bench.
What it does not model
No contact bounce. A slide contact does bounce for a fraction of a millisecond, but a DIP switch is set by hand and left, so nothing reads one fast enough to see it; use the pushbutton for bounce. No contact rating: a real DIP switch carries a few tens of milliamps at most.
Common mistakes
Reading a switch with no pull resistor, so an open switch floats instead of reading 1 or 0. And expecting the numbering to run the same way on both rows: switch 1 is pin 1 on the bottom row and the last pin on the top row.
See it in action
BCD display sets a digit with a 4-way switch, and Switch shifter loads an 8-way switch into a 74HC165. Open them at /templates.