INPUT_PULLUP not working - sorry - noob question

Hi,

I’m trying to get a piece of code running on a seeeduuino XIAO that worked fine on an arduino uno.
Now i’m a bit stuck. Can somebody help me?

I’m working on an alarm which has a closed circuit. When that circuit is cut/disconnected there should be an alert.
On Arduino Uno i used this code:
setup:

int CIRC_pin = 4; // digital 4 as input
pinMode(CIRC_pin, INPUT_PULLUP);

loop:
int CIRC_input_value = digitalRead(CIRC_pin);

On the Uno it gives me a zero when connected and a 1 when disconnected.

The Seeeduino gives me only zeroes all the time. Any idea why?

Any hints very welcome!

Hi elu,
I tried bellow code using a switch and a led.
when press s switch, a led should light ON.

int CIRC_pin = 4; // digital 4 as switch input
int LED_pin = 13; // on board olange LED

void setup() {
  pinMode(CIRC_pin, INPUT_PULLUP);
  pinMode(LED_pin, OUTPUT);
  Serial.begin(9600);
  while(!Serial){}
}

void loop() {
  int CIRC_input_value = digitalRead(CIRC_pin);
  Serial.println(CIRC_input_value);
  digitalWrite(LED_pin, CIRC_input_value);
  delay(100);
}

Hi msfujino,
thanks a LOT! It works perfectly!
elu

1 Like