|
|
| Servo () |
| | Default constructor. Uses the global RPI GPIO instance.
|
| |
|
| Servo (HardwareGPIO_RPI &gpio) |
| | Constructor with explicit HardwareGPIO_RPI instance.
|
| |
| uint8_t | attach (int pin) |
| | Attach the servo to a GPIO pin using default pulse range.
|
| |
| uint8_t | attach (int pin, int min, int max) |
| | Attach the servo to a GPIO pin with custom min/max pulse widths.
|
| |
|
bool | attached () const |
| | Check if the servo is attached to a pin.
|
| |
|
void | detach () |
| | Detach the servo: stop PWM and release the pin.
|
| |
|
int | read () const |
| | Read the current servo position in degrees (0-180).
|
| |
|
int | readMicroseconds () const |
| | Read the current pulse width in microseconds.
|
| |
| void | write (int value) |
| | Write a position to the servo.
|
| |
| void | writeMicroseconds (int us) |
| | Write a pulse width directly in microseconds.
|
| |
Arduino-compatible Servo library for Raspberry Pi.
Uses the Linux sysfs PWM interface via HardwareGPIO_RPI. Supports hardware PWM pins: 12, 13, 18, 19 (BCM numbering).
The servo period is fixed at 50 Hz (20 ms). Pulse widths in the range SERVO_DEFAULT_MIN_US-SERVO_DEFAULT_MAX_US map to 0-180 degrees.
- Note
- Call gpio.begin() on your HardwareGPIO_RPI instance before attaching any servos.
Usage:
HardwareGPIO_RPI gpio;
gpio.begin();
myServo.attach(18);
myServo.write(90);
Arduino-compatible Servo library for Raspberry Pi.
Definition Servo.h:60