CCNAP

TPL-15Templates/DIP Switch 8

DIP Switch 8

Read all 8 switches of a DIP-8 package as a byte. Each closed switch pulls its Arduino pin LOW via INPUT_PULLUP. Flip switches on the canvas and watch the binary value update in the Serial Monitor.

Open in Playgroundbeginner · switch · digital input · serial · DIP · binary
beginner

FIG. 1DIP Switch 8 · circuitTPL-15

02Sketch

sketch.inoArduino C++
19 lines
// DIP Switch 8 — read all 8 switches as a byte
const int PINS[8] = {2, 3, 4, 5, 6, 7, 8, 9};

void setup() {
  for (int p : PINS) pinMode(p, INPUT_PULLUP);
  Serial.begin(9600);
}

void loop() {
  byte val = 0;
  for (int i = 0; i < 8; i++) {
    if (digitalRead(PINS[i]) == LOW) {  // LOW = switch closed
      val |= (1 << i);
    }
  }
  Serial.print("DIP = 0b");
  Serial.println(val, BIN);
  delay(200);
}

03Components

  • 01Arduino Uno
  • 02DIP Switch 8 (wokwi-dip-switch-8)

04Wiring

Component pinArduino pin
1BPin 2
2BPin 3
3BPin 4
4BPin 5
5BPin 6
6BPin 7
7BPin 8
8BPin 9
1A–8A (all tied together)GND (bottom row)

All templates

Ready when you are

Have a circuit in mind?

No hardware, no installs — a browser is enough.