Rotate a Servo Motor

This example shows how to rotate a servo motor by its maximum angle.

Create a raspberrypi object.

mypi = raspi();

Configure a servo object using the PWM pin 9 and set the minimum pulse duration to 1e-3 seconds and the maximum pulse durations to 2e-3 seconds.

s = servo(mypi, 12, 'MinPulseDuration', 1e-3, 'MaxPulseDuration', 2e-3);

Write 1, to turn the motor by the maximum angle.

writePosition(s, 90);

The angle depends on device pulse duration. Refer to your device data sheet for valid pulse duration values.

See Also

| |

Related Topics