I have a Pi3 and I am trying out the example http://pi4j.com/example/listener.html which is a GPIO state listener.

My issue is the following:

When I press (close) the contact, I get one HIGH event.

When I release (open) the contact, I get LOW/HIGH-events permanently.

I tried to debounce() the events:


which really debounces the events. It means, with the contact opened I get only one (in fact two, it's one LOW immediately followed by a HIGH) per second.

I would like to get an event only on state changes.

How can that be achieved?


It could be related to this issue https://github.com/Pi4J/pi4j/issues/121

Only difference is, I don't get the state changes randomly, but permanently in case the contact is open.


Here someone has the same problem: https://groups.google.com/d/msg/pi4j/hdVvEBCpRZc/HOdWFcSyHpIJ


I opened an issue on pi4j's github about this problem: https://github.com/Pi4J/pi4j/issues/300


At the end I was unable to reproduce the issue.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.