Guest User

Untitled

a guest
Nov 18th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import os
  2. import time
  3. os.system("sudo pigpiod") #launch GPIO library
  4. time.sleep(1)
  5. import pigpio
  6.  
  7. ESC = 4
  8. # white wire to 4 (7)
  9. # black wire to 23 (6)
  10.  
  11. pi = pigpio.pi();
  12. pi.set_servo_pulsewidth(ESC, 0)
  13.  
  14. max_value = 2500
  15. min_value = 500
  16.  
  17. def control():
  18. print "Starting motor"
  19. time.sleep(1)
  20. speed = 1900
  21. while True:
  22. pi.set_servo_pulsewidth(ESC, speed)
  23.  
  24. def arm():
  25. print "Connect battery and press Enter"
  26. inp = raw_input()
  27. if inp == '':
  28. pi.set_servo_pulsewidth(ESC, 0)
  29. time.sleep(1)
  30. pi.set_servo_pulsewidth(ESC, max_value)
  31. time.sleep(1)
  32. pi.set_servo_pulsewidth(ESC, min_value)
  33. time.sleep(1)
  34. control()
  35.  
  36. print "Starting..."
  37. arm()
Add Comment
Please, Sign In to add comment