Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
Array is an array of servos controlled by a single PWM peripheral. On most chips, one PWM peripheral can control multiple servos (usually two or four).
func NewArray ¶
NewArray returns a new servo array based on the given PWM, for if you want to control multiple servos from a single PWM peripheral. Using a single PWM for multiple servos saves PWM peripherals for other uses and might use less power depending on the chip.
If you only want to control a single servo, you could use the New shorthand instead.
type PWM ¶
type PWM interface { Configure(config machine.PWMConfig) error Channel(pin machine.Pin) (channel uint8, err error) Top() uint32 Set(channel uint8, value uint32) }
PWM is the interface necessary for controlling typical servo motors.
type Servo ¶
type Servo struct {
// contains filtered or unexported fields
}
Servo is a single servo (connected to one PWM output) that's part of a servo array.
func New ¶
New is a shorthand for NewArray and array.Add. This is useful if you only want to control just a single servo.
func (Servo) SetMicroseconds ¶
SetMicroseconds sets the output signal to be high for the given number of microseconds. For many servos the range is normally between 1000µs and 2000µs for 90° of rotation (with 1500µs being the 'neutral' middle position).
In many cases they can actually go a bit further, with a wider range of supported pulse ranges. For example, they might allow pulse widths from 500µs to 2500µs, but be warned that going outside of the 1000µs-2000µs range might break the servo as it might destroy the gears if it doesn't support this range. Therefore, to be sure check the datasheet before you try values outside of the 1000µs-2000µs range.