# RPi 4 B GPIO.INPUT\_PULLUP does not work

**URL:** https://discourse.processing.org/t/rpi-4-b-gpio-input-pullup-does-not-work/24877
**Category:** Processing for Pi
**Created:** [October 24, 2020, 9:24pm UTC](https://discourse.processing.org/t/rpi-4-b-gpio-input-pullup-does-not-work/24877 "2020-10-24T21:24:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![AlexAlex](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@AlexAlex](https://discourse.processing.org/u/AlexAlex)
#### Post date: [October 24, 2020, 9:24pm UTC](https://discourse.processing.org/t/rpi-4-b-gpio-input-pullup-does-not-work/24877/1 "2020-10-24T21:24:15Z")

</div>

Hello everyone !

I was trying to make the example on processing page:

```auto
	
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
  GPIO.pinMode(17, GPIO.INPUT_PULLUP);
}

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

```

work with my microswitch [https://imgur.com/rxX5hX4](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](https://github.com/Pi4J/pi4j/issues/471) 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 !

---

<div class="post-metadata">

### Author: ![AlexAlex](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@AlexAlex](https://discourse.processing.org/u/AlexAlex)
#### Post date: [October 25, 2020, 6:01pm UTC](https://discourse.processing.org/t/rpi-4-b-gpio-input-pullup-does-not-work/24877/2 "2020-10-25T18:01:41Z")

</div>

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