Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5152

Interfacing (DSI, CSI, I2C, etc.) • Re: Working example of a button with the GPIOd Python API

$
0
0
If you are using the latest gpiod (v2.1.3) from PyPI then the examples in the libgpiod source tree should work for you - you just need to modify them to select the correct line.

You can check what lines are available and on what GPIO chip using the gpioinfo tool from the gpiod package. For Pi5 the external GPIOs are on gpiochip4, whereas for older Pis they are on gpiochip0.
Appreciate your input brother. In your opinion, what would be a better approach? Adding a tiny sleep between loops? I need to check the status of a button in my current program and would greatly appreciate experienced advice!
If you want to know when the button is pressed, look at the watch_line_value.py example - that blocks until the edge event (i.e. the button is pushed), rather than polling.

Statistics: Posted by warthog618 — Tue Apr 02, 2024 2:53 pm



Viewing all articles
Browse latest Browse all 5152

Trending Articles