How to use INPUT_PULLUP with dip switch

I've been trying to read if my dipswitches are on or off to perform different actions, but INPUT_PULLUP doesn't seem to work.
Here's some of my code:

#include <Servo.h>
int valorMap = 0;

int valorFoto = 0;

int miservo = 0;

int valorPot = 0;

Servo servo_2;

void setup()
{

pinMode(A0, INPUT);
pinMode(A4, INPUT_PULLUP);
pinMode(A5, INPUT_PULLUP);
pinMode(A2, INPUT_PULLUP);
pinMode(A3, INPUT_PULLUP);
servo_2.attach(2);
Serial.begin(9600);

}

void loop()
{

int switch1 = digitalRead(A2);
Serial.println(switch1);
int switch2 = digitalRead(A3);
Serial.println(switch2);

if (switch1 == LOW && switch2 == LOW){
valorPot = analogRead(A0);
valorMap = map(valorPot, 0, 1023, 0, 179);
servo_2.write(valorMap);
delay(10); // Delay a little bit to improve simulation performance
}
}

Here's how my dipswitches are connected, yelloew cables are cobected to A2 and A3:

Let’s see an image of the bottom (lead side) of the switches.
The two switch leads need to strattle the center of the breadboard

Hello
post a picture of your hardware setup.

You have shorted out the switches by plugging into the same connector rows - DIP components go across the gap between rows, which is 0.3" wide for that purpose.

That was really helpfull, it worked. Thank You

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.