This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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