Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. //something like this
  2. import RPi.GPIO as GPIO
  3. import time
  4.  
  5. channel = 17
  6. GPIO.setmode(GPIO.BCM)
  7. GPIO.setup(channel, GPIO.IN)
  8. count = 0
  9.  
  10. def callback(channel):
  11. if GPIO.input(channel):
  12. print " PWM high value"
  13. count += 1
  14. else:
  15. print " PWM Low value"
  16.  
  17. GPIO.add_event_detect(channel, GPIO.BOTH, bouncetime=300)
  18. #assign callback function to GPIO pin
  19. GPIO.add_event_callback(channel, callback)
  20.  
  21. while True:
  22. time.sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement