INPUT_PULLUP not working - sorry - noob question


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:

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

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);

void loop() {
  int CIRC_input_value = digitalRead(CIRC_pin);
  digitalWrite(LED_pin, CIRC_input_value);

Hi msfujino,
thanks a LOT! It works perfectly!

1 Like