Alwyn
Posts: 3
Joined: Fri Feb 03, 2023 9:08 am

Using 2 GP Pins to establish a button click

Mon Mar 27, 2023 1:39 pm

Hi,
If I can pass current through 2 "GP" pins rather than just one GP pin and GND I should be able to set up more buttons. I need about 70 buttons.
I have tried with the following code:-
button_14_16 = Pin(14, Pin.IN, Pin.PULL_DOWN) and Pin(16, Pin.IN, Pin.PULL_DOWN)

Each button will have an associated LED to indicate the choice made. So the LEDs will also have to be coded similarly, such as:-
LED_14_17 = Pin(14, Pin Out) and Pin(17, Pin.OUT)

I believe I have seen Pico code similar to the above somewhere but can't find it.

(I do appreciate that using interrupts would be better, but I am using polling to start with.)

Am I on the right track?

Thanks!
Alwyn

User avatar
neilgl
Posts: 6091
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: Using 2 GP Pins to establish a button click

Mon Mar 27, 2023 2:20 pm

Sounds like you are wanting a “keyboard matrix” layout with n rows and m columns e.g. 7 x 10.
Have a look at that
Also see https://forums.raspberrypi.com/viewtopic.php?t=246925 and others

Return to “Advanced users”