IoTSimulator

DIP Switch 8: How It Works, Wiring, and Example Code

An eight-position binary switch used for Arduino configuration, address setting, and simple on-off input testing.
M
Muhammad Ichsan
DIP Switch 8

This article is a guide about the DIP Switch 8. We will explain what the switch bank is, how it works, how to wire it, and how to read the switch states from Arduino code. DIP switches are useful when a project needs several stable on/off settings in a compact format. They are especially handy when you want a physical setting that stays put instead of a button you must keep pressing.

Description

DIP Switch 8 real product
DIP Switch 8 real product

The DIP Switch 8 is a bank of eight tiny switches in one package. Each switch can be turned on or off independently, which makes the part useful for configuration settings, address selection, feature toggles, and binary input experiments.

Unlike a joystick or potentiometer, a DIP switch does not give a changing analog value. It gives you a set of clear digital states that stay where you leave them until you move the switch again. That is why it feels more like a tiny control panel than a sensor.

The wider DIP-switch family also includes other styles such as slide and rotary versions, but this 8-position bank is the familiar version for simple on/off settings. It is easy to understand, easy to test, and easy to use when a project needs a fixed hardware choice.

Features

Here are the main things to know about the DIP Switch 8:

FeatureWhat it means
Eight inputsLets you control eight separate on/off states.
Binary styleUseful for setting values in bits and small codes.
Stable positionStays in place until you move a switch again.
Simple wiringEasy to connect with pull-up logic and digital inputs.
Configuration friendlyGood for board addresses, mode selection, and options.
Maintained inputPerfect for settings that should not change by accident.

The important part is that each switch acts like a small maintained input, so the Arduino can read a whole group of settings all at once. In real use, that is what makes it better for setup choices than for fast user interaction.

How Does It Work?

Each tiny switch inside the DIP package connects or disconnects a circuit path. When a switch is on, the Arduino sees one logic state. When it is off, the Arduino sees the other state. That simple contact change is the whole trick behind the module.

How the DIP Switch 8 works
How the DIP Switch 8 works

Because the switches are independent, the sketch can read all eight positions and combine them into a binary number or a set of separate options. In practice, that means one small switch bank can replace a long string of hard-coded choices in your sketch.

This is why DIP switches are often used for configuration. They let a human choose a value before the board starts its main task, which is much more convenient than editing code every time you want to test a new mode.

Binary Value

Each switch can represent one bit. Eight switches can therefore represent values from 0 to 255, which is useful for addresses or configuration codes. That range is one reason the part shows up so often in board setup and binary input examples.

Stable Input

Because the switch stays in the chosen position, the Arduino can read it repeatedly without the state changing unless the user touches the hardware again. That is different from a pushbutton, which only stays active while you press it.

Active Low Wiring

A lot of beginner sketches read DIP switches with pull-up resistors. In that setup, an open switch reads HIGH and a closed switch pulls the pin LOW. This is a clean wiring pattern because the input never floats.

Pinout

DIP Switch 8 anatomy and pinout
DIP Switch 8 anatomy and pinout

The connection map tells you which pins matter most when wiring the module to an Arduino. Match the shared side and the read pins carefully so the circuit behaves the way the sketch expects.

In this simulator, the DIP switch exposes sixteen pins: eight on one side and eight on the other. The switches are arranged as paired contacts, so each row position can be read as an independent on/off input. That is why the pinout feels simple once you understand that each switch is just a bridge between two pads.

Pin Role

In a basic input setup, one side of each switch connects to ground or power, and the other side connects to the Arduino input. Using a pull-up or pull-down arrangement keeps the reading stable. For this article's example, pull-up wiring is the easier choice because the Arduino can handle the default HIGH state on its own.

Pin GroupRoleConnectionNotes
1a-8aCommon sideGNDThese pins share the ground reference for the active-low setup.
1b-8bSignal sideD2 to D9These pins go to the Arduino inputs so each switch can be read as a bit.

Arduino With DIP Switch 8

The Arduino setup is simple: the switch bank feeds eight digital inputs, and the Arduino reads them as a fixed binary pattern. In this example, the switch positions are wired to pins D2 through D9, which matches the sketch below.

A common use case for this setup is a hardware configuration panel. You can use the switch bank to pick a board address, enable or disable a feature, or choose which mode the sketch should start in without opening the code editor.

SCL
SDA
AREF
GND.1
D13
D12
D11
D10
D9
D8
D7
D6
D5
D4
D3
D2
D1
D0
IOREF
RESET
3V3
5V
GND.2
GND.3
VIN
A0
A1
A2
A3
A4
A5
1a
2a
3a
4a
5a
6a
7a
8a
8b
7b
6b
5b
4b
3b
2b
1b

Pin Connection

The pin connection is simple once you split the switch bank into a common side and a signal side. The table below shows how each row maps into the Arduino input pins used by the sketch.

Pin Connection Map
Switch Pin
1a-8a
Arduino Pin
GND
Explanation

The common side of the switch bank shares ground so the pull-up logic stays stable.

Switch Pin
1b
Arduino Pin
D2
Explanation

Reads bit 1 from the switch bank.

Switch Pin
2b
Arduino Pin
D3
Explanation

Reads bit 2 from the switch bank.

Switch Pin
3b
Arduino Pin
D4
Explanation

Reads bit 3 from the switch bank.

Switch Pin
4b
Arduino Pin
D5
Explanation

Reads bit 4 from the switch bank.

Switch Pin
5b
Arduino Pin
D6
Explanation

Reads bit 5 from the switch bank.

Switch Pin
6b
Arduino Pin
D7
Explanation

Reads bit 6 from the switch bank.

Switch Pin
7b
Arduino Pin
D8
Explanation

Reads bit 7 from the switch bank.

Switch Pin
8b
Arduino Pin
D9
Explanation

Reads bit 8 from the switch bank.

With INPUT_PULLUP enabled, the Arduino reads HIGH when a switch is open and LOW when it is closed. That active-low pattern keeps the inputs stable and makes the switch bank easier to debug in a simple Arduino sketch.

With INPUT_PULLUP enabled, an open switch reads HIGH and a closed switch reads LOW. That active-low pattern keeps the inputs stable and makes the switch bank easier to debug in a simple Arduino sketch.

Code

This example reads eight switch states and prints both the bit pattern and the final value to Serial Monitor so you can see the configuration settings change. It is a helpful first sketch because it shows how a physical switch position becomes a number in code.

C++ Source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

Once that works, you can use the switch bank to set addresses, choose modes, or enable and disable features in your project. That is the main reason people keep using DIP switches even though the part looks very simple.

How The Code Works, Part By Part

Let's break the sketch into smaller pieces so the flow is easier to understand and easier to modify later.

Pin Array

The code begins by listing the eight Arduino pins connected to the switch bank. That makes the rest of the sketch easier to read and change later. When the pin list is clear, the binary logic becomes much easier to follow.

C++ Source
1

Input Mode

The setup block turns on the internal pull-up resistors. That keeps the input stable and avoids floating readings in a simple wiring setup. This is one of those small details that saves beginners a lot of confusion.

C++ Source
1
2
3
4
5
6

Read Switches

The loop checks every switch one by one. If a switch is active, the code adds that bit to the output value. In other words, the sketch is turning a row of tiny settings into one binary number.

C++ Source
1
2
3
4
5
6

Print Value

Printing the final value lets you see the combined switch state in one number, which is very helpful for addresses or option codes. It also gives you a quick way to confirm that the switch order matches your wiring plan.

C++ Source
1
2
3
4
5
6
7

Repeat

The delay gives the serial output a little breathing room while the sketch keeps checking the switch bank.

C++ Source
1
2

Wrapping Up

The DIP Switch 8 is a simple but powerful input part when you want a fixed set of binary options.

Once you understand the pull-up logic, the bit pattern, and the switch positions, you can use it confidently in configuration and control projects. It is one of the clearest parts for learning how hardware settings become code values.

If the output looks backwards, the first thing to check is the bit order and which switch maps to which Arduino pin. After that, you can reuse the same pattern for mode selection, startup options, and any project that needs a small hardware setting panel.

New

Wait! We're building more...

Our laboratory is currently preparing a lot of exciting new projects using DIP Switch 8. Stay tuned for the upcoming massive update!

Projects Using DIP Switch 8

Explore practical implementations

No official projects found for this component yet.

Muhammad Ichsanul Fadhil
About Writer

Muhammad Ichsanul Fadhil

"I'm a developer and hardware enthusiast with a passion for IoT. I love experimenting with new components and writing down everything I learn to help others build their own projects."

Share this article

Share it with your favorite channel.