RPi 4 B GPIO.INPUT_PULLUP does not work

Hello everyone !

I was trying to make the example on processing page:

import processing.io.*;

// On the Raspberry Pi GPIO 4 is physical pin 7 on the header

void setup() {
  // INPUT_PULLUP enables the built-in pull-up resistor for this pin
  // left alone, the pin will read as HIGH
  // connected to ground (via e.g. a button or switch) it will read LOW

void draw() {
  if (GPIO.digitalRead(17) == GPIO.LOW) {
    // button is pressed
  } else {
    // button is not pressed
  ellipse(width/2, height/2, width*0.75, height*0.75);

work with my microswitch https://imgur.com/rxX5hX4
(ground to COM, GPIO to NO)

However I think the pull-up might not be working (I always get GPIO.digitalRead() == GPIO.LOW). I am using GPIO pin 17 and ground pin 9.

But whenever I try to turn on a LED with the same cables and setup it works just fine. And then when I switch those cables to the switch again instead of nothing I actually get a flickering. And then when I push the switch I get GPIO.HIGH. So the switch must work fine aswell. Upon restarting the pi it is again only gpio.low no matter what.

I came across this and will try the suggested workaround (changing the /boot/config.txt), however I was wondering if there is any more elegant solution to this ? Also do I understand it correctly, that installing wiringpi as mentioned at the end , should not make a a difference since I am working with processing ?

Thank you for any thoughts on this !

Alright adding : gpio=17=pu,ip
to the boot/config.txt file solved the issue, but that is not a very nice solution :frowning: