1

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:

myButton.setDebounce(1000);

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?

Edit1

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.

Edit2

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

Edit3

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

Edit4

At the end I was unable to reproduce the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.