I'm planning to integrate a servo motor with a raspberry PI to press a switch button and found this post very helpful :

PWM Control on Raspberry PI

I'm considering this motor VicTsing Mini SG90 9g Micro Servo Motor for RC Robot Helicopter Airplane controls Car Boat ( http://www.amazon.co.uk/VicTsing-Micro-Helicopter-Airplane-controls/dp/B00J593UM2/ref=sr_1_6?ie=UTF8&qid=1454154678&sr=8-6&keywords=servo+motor to connect with PI )

Will I require other hardware components to connect this with PI excluding the PI power source & sd card for Raspian OS ?


You only need additional hardware if the servo draws more power than the Pi can safely supply. In that case the required additional hardware is a suitable power supply.

The Pi should be able to power your 9g servo as long as the servo is powerful enough to depress the button without stalling.

So connect servo 5V to a 5V pin, servo ground to a Pi ground pin, and servo control to a Pi GPIO.

My pigpio library can generate the needed servo pulses on any GPIO on the expansion header.


Will I require other hardware components to connect this with PI

No. I have a pile of SG90s. You attach the ground (brown wire) to a ground pin on the pi, the + voltage (red) to a 5V pin on the pi, and the control (yellow) wire to the GPIO you want to use for PWM. Note I have never tried more than 2 at a time on the pi.

With regard to PWM, the accepted answer on the other question there says you can use any pin and presumably that's true, but I suggest you try a dedicated pin first (GPIO 18, and on +/2 models 12, 13, 19)1 and compare this to the other options to make sure you are getting the functionality you want.

1. Note there are only two channels in total for the PWM clock, so if you use more than two pins with that clock, they will be doing the same thing (presuming that's possible, I have not tried). There's a chart here of the various GPIO pin functions; the relevant ones here are the cyan "PWM0" and "PWM1"; columns in the chart correspond to "ALT" function slots for each pin. You need a special library (pigpio, wiringPi, or libbcm2835) to set these and the documentation for such should have an explanation of setting the ALT functions and how to manipulate the PWM clock.

  • 1
    Pis with the 40 pin expansion header (and the compute module) have two accessible hardware PWM channels which may be routed to GPIO 12/13/18/19. – joan Jan 30 '16 at 12:54
  • Oh yeah. I hadn't noticed 12 and 13 before for some reason. :/ – goldilocks Jan 30 '16 at 12:57

No, you do not need other component(s) except maybe for an external power supply since the Pi can only handle so much.

Here's a great Adafruit link all about controlling servo motors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.