Part

4-way DIP switch

Four little switches in a chip-sized body.

See every part
  • 8 pins
  • 1 setting
  • In 1 project
  • In 1 lesson
Drawn live by the editor's own code, at the size you see it.
At a glance

The 4-way DIP switch in brief

What it is, and every setting the properties panel gives it.

A 4-way DIP switch is four tiny slide switches in the body of a chip that sits across the breadboard’s center channel, with pins 1A to 4A along the bottom and 1B to 4B along the top. Switch n joins nA to nB when its lever is up toward ON, and no two switches share a pin. Wire it like four pushbuttons: the A side of every switch to ground and each B side to an Arduino Uno or ESP32 input with a pull-up, so an on switch reads 0 and an off switch reads 1. Mokxi models each closed switch as a 50 milliohm contact that passes current either way and each open one as two floating pins. The on property is a bitmask of where the switches start, bit 0 for switch 1, so 5 means switches 1 and 3. The classic mistakes are leaving out the pull resistors and assuming both rows number the same way, when switch 1 is first on the bottom row and last on the top. Contact bounce and current rating are not modeled.

Family
Inputs
Pins
8
on
0
Pins

8 pins

Named as the editor names them, so a wire lands where you expect it.

  • 1A
  • 2A
  • 3A
  • 4A
  • 4B
  • 3B
  • 2B
  • 1B
How to use it

How to use a 4-way DIP switch with an Arduino

Treat it as four separate switches. On an Arduino, wire one side of every switch to GND and each other side to its own digital pin set to INPUT_PULLUP; an on switch then reads LOW. Read all four pins and add up the bits, switch 1 worth 1, switch 2 worth 2, switch 3 worth 4 and switch 4 worth 8, to get a number from 0 to 15.

The circuit here does the same job with no processor: the B side of every switch goes to 5 V, a 10 k resistor network pulls each A side to ground, and a CD4511 turns the four bits into a digit. Wired this way, an on switch reads 1. It starts on 5, switches 1 and 3.

Part pin
Board pin
1B, 2B, 3B, 4B
5 V
1A, 2A, 3A, 4A
CD4511 inputs A, B, C, D
10 k resistor network
Each A side to GND
BCD display on a CD4511live0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
How it is modeled

What is true about the 4-way DIP switch, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

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.

Not modeled

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.

From DIP switch (4 and 8 way), in full.

Projects

See the 4-way DIP switch in a project

One built-in project uses it. It opens in the editor, already wired.

Lessons

Where it turns up in a lesson

One lesson places it in its own circuit.

Wire up the 4-way DIP switch

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.