daily pastebin goal
0%
SHARE
TWEET

Untitled

a guest Oct 10th, 2016 124 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from gpiozero import Robot, LED, DistanceSensor
  2. from time import sleep
  3.  
  4. enable_l = 18
  5. enable_r = 13
  6. left = (12, 16)
  7. right = (23, 24)
  8.  
  9. #enable_l_object = PWMOutputDevice(enable_l)
  10. #enable_r_object = PWMOutputDevice(enable_r)
  11.  
  12. #enable_l_object.value(0.1)
  13. #enable_r_object.value(0.1)
  14.  
  15. enable_l_object = LED(enable_l)
  16. enable_r_object = LED(enable_r)
  17.  
  18. test_LED = LED(1)
  19.  
  20. enable_l_object.on()
  21. enable_r_object.on()  
  22.  
  23. robot = Robot(left=left, right=right)
  24.  
  25. sensor = DistanceSensor(echo=21, trigger=20)
  26.  
  27. while True:
  28.     x = sensor.distance
  29.     if (x<0.2):
  30.         test_LED.on()
  31.     else:
  32.         test_LED.off()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top