pi2servo

USING SERVOS ON THE PI

Servos are an inexpensive and easy way to make things move. With some slight modification to it's connector, a single servo can be plugged directly into the Pi.

To set things up run the following commands. They have to be done in this order!

 

    /usr/bin/gpio -g mode 18 pwm

    /usr/bin/gpio -g pwm 18 150

    /usr/bin/gpio pwm-ms

    /usr/bin/gpio pwmc 192

    /usr/bin/gpio pwmr 2000

To make the servo move to the right run:

    /usr/bin/gpio -g pwm 18 100

To make the servo move to the left run:

    /usr/bin/gpio -g pwm 18 200

To make the servo move to the center run:

    /usr/bin/gpio -g pwm 18 150

You can use other values than these. They should be between 100 and 200. Try some out.

Do some testing to see the minimum change in the value that makes the servo move. For instance if the servo is at 150, does telling it to move to 151 do anything? Or do you need to tell it to move to 152 before any motion happens?