0

GPIO Input Question
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

GPIO Input Question

by Sigma_San on Sat Apr 03, 2021 6:34 pm

I'm working on a project that involves a lot of buttons. Would it be possible to map multiple buttons to one M4 Express GPIO pin using CircuitPython?

Sigma_San
 
Posts: 7
Joined: Wed Dec 30, 2020 4:33 pm

Re: GPIO Input Question

by danhalbert on Sat Apr 03, 2021 6:44 pm

There's several ways to do this. You use an external device that can support many pins and then ask it for their values:

I2C GPIO expanders: Look at the first few hits on this: https://www.adafruit.com/?q=expander&sort=BestMatch. We have CircuitPython drivers for these devices, and there are Learn Guides:
https://learn.adafruit.com/adafruit-aw9 ... led-driver
https://learn.adafruit.com/using-mcp230 ... cuitpython

shift registers: https://www.adafruit.com/?q=shift+regis ... =BestMatch. Also have libraries and Learn Guides:
https://learn.adafruit.com/74hc595

danhalbert
 
Posts: 2332
Joined: Tue Aug 08, 2017 12:37 pm

Re: GPIO Input Question

by Sigma_San on Sat Apr 03, 2021 6:48 pm

Is there a method that doesn't involve additional hardware?

Sigma_San
 
Posts: 7
Joined: Wed Dec 30, 2020 4:33 pm

Re: GPIO Input Question

by danhalbert on Sat Apr 03, 2021 6:58 pm

You need a way to distinguish one button being pushed from another. Another trickier way is to add a chain of resistors to the buttons, and measure the voltage, which will vary based on which buttons are pressed. But that's still extra hardware

danhalbert
 
Posts: 2332
Joined: Tue Aug 08, 2017 12:37 pm

Re: GPIO Input Question

by danhalbert on Sat Apr 03, 2021 7:01 pm


danhalbert
 
Posts: 2332
Joined: Tue Aug 08, 2017 12:37 pm

Re: GPIO Input Question

by Sigma_San on Sat Apr 03, 2021 7:05 pm

So will the method with the resistors still work on GPIO pins?

Sigma_San
 
Posts: 7
Joined: Wed Dec 30, 2020 4:33 pm

Re: GPIO Input Question

by danhalbert on Sat Apr 03, 2021 7:31 pm

With resistors you'd need a pin that can be analog, so you might want to use the button grids with or without diodes.

danhalbert
 
Posts: 2332
Joined: Tue Aug 08, 2017 12:37 pm

Re: GPIO Input Question

by Sigma_San on Sat Apr 03, 2021 7:33 pm

OK. Thanks!

Sigma_San
 
Posts: 7
Joined: Wed Dec 30, 2020 4:33 pm

Please be positive and constructive with your questions and comments.


cron