Can't get input button to work

I have set up a simple circuit from, but the button won’t work. The previous exercise with the LED was fine.


Hi Glenn
Is the button actually closing the correct pins. Some buttons have 4 pins and if inserted 90º out it should (or maybe not) look like it is on all the time.

Another possibility check the proto board you are using. Some of these have not got the pos and /or neg rails connected all the way along. Look at the red or blue line. If it has ay breaks between groups of holes it will not be connected and you will have to link the groups.

Otherwise you will have to do some sleuthing.
Cheers Bob

Thanks Bob. Had my button wired to gnd and not +ve… oops :blush:

1 Like

Those print commands are very useful.

Hi Glenn,

Glad to hear it was something simple!

For next time, remember that the Pico can pull both a pin up or down internally, or leave it floating, so you could connect your button to ground if that was easier, provided you had an internal pullup (set in software) or an external pullup (a resistor between the pin and 3.3V).

A bit more info here if you need it:

Thank you for that. I thought "PULLUP” meant there was actually a resistor installed. Pretty amazing you can simulate one, making the Pico an amazing device.

Hi @James

That’s awesome! Is this something the Arduino is capable of as well?

Pullup only on the Arduino, but it is available for all the GPIO pins.

Digital Input Pull-Up Resistor | Arduino Documentation
pinMode() - Arduino Reference

1 Like

pinMode(2, INPUT_PULLUP);
Ah that’s really useful. Thanks @Jeff105671 !