I am attempting to rewrite a bit of code that used gpiozero for a Raspberry Pi that no longer works on the Raspberry Pi 5 due to the GPIO changes in the Raspi 5. I need it to be backwards compatible to possibly run on our Raspi 2's that we were using, so the gpiod lib seems like the best choice. However, example code here (specifically using the get line value example) and here but the ACTIVE value doesn't appear to change when I push the button. These are the same buttons that worked using gpiozero, so I'm assuming I'm doing something wrong in the api implementation. However, I have no baseline to check from because I cannot find any working example code that uses a modern implementation of this library. Maybe it doesn't exist? That is my question:
Does anyone know of any or could anyone write working example code for a button that works with the modern gpiod library that I could reference? If not, could anyone suggest where else I might look besides the "active" value of a pin? Maybe I'm looking at the wrong value and just don't know it?
Would really appreciate any direction that anyone would be willing to offer in this case.
Thank you in advance!
EDIT: I did get my LED's switched over, so I know at least what I'm doing with LED's is working. Thanks to the example LED code here for pointing the way. Buttons don't seem to work this way, however.
-
Include simple code examples, not links in your question.CoderMike– CoderMike2024年03月29日 18:19:54 +00:00Commented Mar 29, 2024 at 18:19
-
A code example is exactly what I'm asking for.utdream– utdream2024年03月29日 18:36:42 +00:00Commented Mar 29, 2024 at 18:36
-
Include examples of what is not working, I can't find what your referring to in the links.CoderMike– CoderMike2024年03月29日 18:52:03 +00:00Commented Mar 29, 2024 at 18:52
-
1If you have the latest gpiozero (v2.0.1) and use the default library lgpio it should work. If you have code you claim doesn't work post with diagnostics.Milliways– Milliways2024年03月29日 20:58:06 +00:00Commented Mar 29, 2024 at 20:58
-
1This question could be vastly simplified by simply editing the question to add a copy of the code that does not work. After all the comments and discussion it seems that's not going to happen. Consequently, I’m voting to close this question.Seamus– Seamus2024年03月29日 23:35:50 +00:00Commented Mar 29, 2024 at 23:35
1 Answer 1
I have some code using gpiod.
See https://raspberrypi.stackexchange.com/a/145544/8697
gpiod is poorly documented so it is not easy to use but my test worked but not fully tested on Pi5
-
Thank you. Your helpfulness is greatly appreciated. I'll keep hacking away at this and your example code will be very useful in my testing. I will respond with working code if I can figure it out. =)utdream– utdream2024年04月01日 15:57:31 +00:00Commented Apr 1, 2024 at 15:57