Tom_Jung

Untitled

Feb 2nd, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. from gpiozero import DistanceSensor
  2.  
  3. ultrasonic = DistanceSensor(echo = 17, trigger = 4)
  4.  
  5. ultrasonic.distance
  6.  
  7. ultrasonic.max_distance = 1
  8.  
  9. ##while True:
  10. ## print(ultrasonic.distance)
  11. ##
  12.  
  13. ##while True:
  14. ## ultrasonic.wait_for_in_range()
  15. ## print("In range")
  16. ## print(ultrasonic.distance)
  17. ##
  18. ## ultrasonic.wait_for_out_of_range()
  19. ## print("Out of range")
  20. ## print(ultrasonic.distance)
  21. ##
  22. ##ultrasonic.threshold_distance = 0.5
  23.  
  24. def hello():
  25. print("Hello")
  26.  
  27. def bye():
  28. print("Bye")
  29.  
  30.  
  31. ultrasonic.when_in_range = hello
  32.  
  33. ultrasonic.when_out_of_range = bye
Advertisement
Add Comment
Please, Sign In to add comment