mirror of
https://github.com/wahyd4/raspberry-pi.git
synced 2026-08-09 04:46:15 +10:00
Create servo-test.py
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user