2025-01-04 17:50:27 +01:00
|
|
|
|
import math
|
2024-12-25 16:52:07 +01:00
|
|
|
|
from adafruit_servokit import ServoKit
|
|
|
|
|
|
|
|
|
|
|
|
kit = ServoKit(channels=16)
|
2025-01-04 17:50:27 +01:00
|
|
|
|
MIN_PULSE = 400 # Defines angle 80, for current PID setup -- 550
|
|
|
|
|
|
MAX_PULSE = 2500 # Defines angle 100, for current PID setup -- 2450
|
|
|
|
|
|
kit.servo[0].set_pulse_width_range(MIN_PULSE, MAX_PULSE)
|
|
|
|
|
|
# kit.servo[0].set_pulse_width_range(MIN_PULSE, MAX_PULSE)
|
2024-12-25 16:52:07 +01:00
|
|
|
|
# Control the minimum and maximum range of the servo.
|
|
|
|
|
|
# min_pulse (int) – The minimum pulse width of the servo in microseconds.
|
|
|
|
|
|
# max_pulse (int) – The maximum pulse width of the servo in microseconds.
|
2025-01-04 17:50:27 +01:00
|
|
|
|
# kit.servo[0].set_pulse_width_range(500, 2500)
|
2024-12-25 16:52:07 +01:00
|
|
|
|
|
|
|
|
|
|
# Pulse width expressed as fraction between 0.0 (`min_pulse`) and 1.0 (`max_pulse`).
|
|
|
|
|
|
# For conventional servos, corresponds to the servo position as a fraction
|
|
|
|
|
|
# of the actuation range. Is None when servo is disabled (pulsewidth of 0ms)
|
|
|
|
|
|
# kit.servo[0].fraction = 0.5
|
|
|
|
|
|
|
|
|
|
|
|
# property angle: float | None
|
|
|
|
|
|
# The servo angle in degrees. Must be in the range 0 to actuation_range.
|
|
|
|
|
|
# Is None when servo is disabled.
|
2025-01-04 17:50:27 +01:00
|
|
|
|
|
2025-01-05 22:02:02 +01:00
|
|
|
|
kit.servo[0].angle = 90
|
2025-01-04 17:50:27 +01:00
|
|
|
|
|
2024-12-25 16:52:07 +01:00
|
|
|
|
|
|
|
|
|
|
# property throttle: float
|
|
|
|
|
|
# How much power is being delivered to the motor.
|
|
|
|
|
|
# Values range from -1.0 (full throttle reverse) to 1.0 (full throttle forwards.)
|
|
|
|
|
|
# 0 will stop the motor from spinning.
|
2025-01-04 17:50:27 +01:00
|
|
|
|
# kit.continuous_servo[0].throttle = 0.5
|
2024-12-25 16:52:07 +01:00
|
|
|
|
|
|
|
|
|
|
# property actuation range: float | None
|
|
|
|
|
|
# The servo angle in degrees. Must be in the range 0 to actuation_range.
|
|
|
|
|
|
# Is None when servo is disabled
|
|
|
|
|
|
#kit.servo[0].actuation_range = 120
|