2
from gpiozero import Button
btn = Button(4)
while True:
    print("begin")
    btn.wait_for_press()
    print("Pressed")
    btn.wait_for_release()
    print("Released")

This code worked at first but now I get runtime error:

failed to add edge detection. 

What did I do wrong?

  • What have you done between the time it worked and the time it stopped working? – joan May 18 '17 at 21:47
  • are you running the code as root? – Mohammad Ali May 19 '17 at 2:44
  • @MohammadAli The code should not need to be run as root. – joan May 19 '17 at 7:38
  • @joan yes but it seems be the thing that he could most likely be doing differently from when his code originally worked – Mohammad Ali May 19 '17 at 12:43

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.