Hi All, I’m trying to write some code to detect that a button was pushed. I wrote the code below, but it thinks the button is always pushed, except when I actually push it. When I push and hold it, the output stops. The button is wired between the GPIO pin and GND, with no pullup resistor since there is an internal pullup. I wonder if my code is wrong and would appreciate your comments, thank you.
As it turns out, GPIO pins 34, 35, 36 and 39 are actually GPI - input only and have no internal pullup or pulldown resistors. I switched to a different GPIO with internal pullup and this solved the problem.
I don’t think you need to switch to other pins. I’m successfully using pin 36 for my push button. But I do need to set “pull up” in code. Below a snippet of my code. It is in mJS/JavaScript, but the method signatures are similar.