How to: Servo Motor¶
First initialize the servo output by calling function
twr_servo_init (twr_servo_t *self, twr_pwm_channel_t channel)
channel parameter can be one of the output pins. Please check the Core Module pinout to see which pins allows PWM.
1TWR_PWM_P0 2TWR_PWM_P1 // Power Module LED connector 3TWR_PWM_P2 4TWR_PWM_P3 5TWR_PWM_P6 6TWR_PWM_P7 7TWR_PWM_P8 8TWR_PWM_P12 9TWR_PWM_P14
The TWR_PWM_P1 is special, because it’s connected to the DATA signal on the Power Module. This way you can connect the servo directly to the 3 pins instead of digital LEDs. You have to use power adapter to power the servo! The USB +5V is not connected to the Power Module.
Then you can control the servo signal and the servo movement.
You can use function to set the pulse length in microseconds or you can write directly the desired angle between the
1twr_servo_set_microseconds (twr_servo_t *self, uint16_t us) 2twr_servo_get_angle (twr_servo_t *self)
In case you need to tune the pulse length limits. Use