Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. from gpiozero import Button
  2. from time import sleep
  3.  
  4. aBtn = Button(6)
  5. bBtn = Button(13, pull_up=False)
  6.  
  7. def buTest(but):
  8. sleep(0.5) #adjust to your liking
  9. act = but.is_active
  10. if act:
  11. # long press action here
  12. print('Button {} long press'.format(str(but.pin)))
  13. else:
  14. #short press action here
  15. print('Button {} short press'.format(str(but.pin)))
  16.  
  17. aBtn.when_pressed = buTest
  18. bBtn.when_pressed = buTest
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement