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.
1 2 3 4 5 6 7 8 9
TWR_PWM_P0 TWR_PWM_P1 // Power Module LED connector TWR_PWM_P2 TWR_PWM_P3 TWR_PWM_P6 TWR_PWM_P7 TWR_PWM_P8 TWR_PWM_P12 TWR_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
twr_servo_set_microseconds (twr_servo_t *self, uint16_t us) twr_servo_get_angle (twr_servo_t *self)
In case you need to tune the pulse length limits. Use