Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #
  3. # https://www.dexterindustries.com/GoPiGo/
  4. # https://github.com/DexterInd/GoPiGo3
  5. #
  6. # Copyright (c) 2017 Dexter Industries
  7. # Released under the MIT license (http://choosealicense.com/licenses/mit/).
  8. # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
  9. #
  10. # This code is an example for controlling the GoPiGo3 Servos
  11. #
  12. # Results: When you run this program, the GoPiGo3 Servos will rotate back and forth.
  13.  
  14. from __future__ import print_function # use python 3 syntax but make it compatible with python 2
  15. from __future__ import division # ''
  16.  
  17. import time # import the time library for the sleep function
  18. import gopigo3 # import the GoPiGo3 drivers
  19.  
  20. GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
  21.  
  22. try:
  23. while True:
  24. for i in range(1000, 2001): # count from 1000 to 2000
  25. GPG.set_servo(GPG.SERVO_1, i)
  26. #GPG.set_servo(GPG.SERVO_2, 3000-i)
  27. time.sleep(0.01)
  28.  
  29. for i in range(1000, 2001): # count from 1000 to 2000
  30. #GPG.set_servo(GPG.SERVO_2, i)
  31. GPG.set_servo(GPG.SERVO_1, 3000-i)
  32. time.sleep(0.01)
  33.  
  34. except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
  35. GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement