mirror of
https://github.com/wahyd4/raspberry-pi.git
synced 2026-08-09 04:46:15 +10:00
29 lines
511 B
Python
29 lines
511 B
Python
from adafruit_servokit import ServoKit
|
|
import atexit
|
|
import RPi.GPIO as GPIO
|
|
import time
|
|
GPIO.cleanup()
|
|
kit = ServoKit(channels=16)
|
|
|
|
start = 180
|
|
end = 0
|
|
|
|
print("hello starting")
|
|
|
|
kit.servo[0].actuation_range = 180
|
|
|
|
# angle can be 0 - 180
|
|
kit.servo[0].angle = start
|
|
time.sleep(1)
|
|
kit.servo[0].angle = end
|
|
time.sleep(1)
|
|
# kit.servo[2].angle = start
|
|
# kit.continuous_servo[2].throttle = 1
|
|
|
|
time.sleep(3)
|
|
def exit_handler():
|
|
GPIO.cleanup()
|
|
print('My application is ending!')
|
|
|
|
atexit.register(exit_handler)
|