I have a python script which have a pyqt5 Gui and I want in this Gui to know if a certain pin is toggeld. I did use

GPIO.setup(7, GPIO.IN)
GPIO.add_event_detect(7, GPIO.RISING, callback = change, bouncetime=3)
def change(channel):
    channel_is_on =GPIO.input(channel)

so what I received after I hooked the jumper was always 1 even I didn't turn it on. first how can I read just the toggle when it happen? what is the problem that the pin read high when it been hooked up?


The callback is only set up for rising edges. Change it to wait for both edges.

  • may be it's the solution but I still get the 1s after hooking the jumper , therefore I cannot confirm it – Izo Oct 7 '20 at 13:28
  • What is connected to the GPIO? If nothing is connected it will randomly return 0 or 1. Add a pull. – joan Oct 7 '20 at 14:49
  • I do actually connect it to pulse generator. I used Pull down resistance and it worked and but even that I'm using the GPIO.BOTH it return just 0 have you an idea how can solve it – Izo Oct 7 '20 at 15:22
  • 2
    No. You need to add all clarifications to your question. It is almost always a mistake to read a GPIO level in a callback. – joan Oct 7 '20 at 15:38

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.