Origin’s servo control is built around the PCA9685 16-channel PWM driver, accessed over I2C using the Adafruit ServoKit library. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/boblio-max/origin/llms.txt
Use this file to discover all available pages before exploring further.
set servo.angle command gives you direct, angle-based control over any of the 16 available servo channels with a single readable statement — no PWM math, no duty-cycle calculations, and no manual library initialization required.
Syntax
n— the PCA9685 channel number,0through15deg— the target angle in degrees
set, then servo as the hardware name, then .angle as the subtype, then the channel number n, then a comma, and finally the angle deg. The interpreter translates this into the following Python:
ServoKit instance (_kit) is lazily initialized once and reused for every subsequent set servo.angle call within the same script, so you pay the I2C setup cost only once.
Angle Clamping
Angle clamping is handled by theadafruit_servokit library itself, not by Origin. The library clamps the value assigned to .angle to the 0–180 degree range. Passing a value below 0 is treated as 0; passing a value above 180 is treated as 180. Origin relies on this library behavior to prevent accidental out-of-range commands that could strain servo gears or stall the motor.
Basic Examples
Center servo channel 1 (90° is the midpoint of the 0–180 range):Full Example: Servo Sweep
This script sweeps servo channel 0 from 0° to 180° in 10° steps, pauses, then sweeps back to 0°.Wire the PCA9685
Connect the PCA9685 board’s SDA and SCL pins to the Raspberry Pi’s I2C1 bus (physical pins 3 and 5). Power the board’s VCC from 3.3 V and connect GND. Power the servo rail (V+) from an external 5–6 V supply — never from the Pi’s 5 V pin.
Enable I2C
Run
sudo raspi-config, navigate to Interface Options → I2C, and enable it. Reboot if prompted.Attach the servo
Connect your servo’s signal wire (usually orange or yellow) to channel 0 on the PCA9685. Do not attach any mechanical load yet.
PCA9685 Board Addressing
The PCA9685 communicates over I2C. Its default I2C address is0x40, which is what Origin uses when ServoKit(channels=16) is initialized. If you have multiple PCA9685 boards on the same bus, you can configure different addresses by bridging the address pads on the board (A0–A5), giving addresses from 0x40 up to 0x7F.
| Address Pads Bridged | I2C Address |
|---|---|
| None (default) | 0x40 |
| A0 | 0x41 |
| A1 | 0x42 |
| A0 + A1 | 0x43 |
py {} block to instantiate ServoKit with a custom address argument and assign it to _kit so subsequent set servo.angle calls reuse your custom instance.
Controlling Multiple Channels
Eachset servo.angle call targets one channel independently. You can control multiple servos in the same script: