Alright so I understand this question is fairly saturated, but my use in pwm is for two differing pieces of hardware.

https://www.modmypi.com/blog/raspberry-pi-gpio-en-franais (Sourced from: https://www.modmypi.com/blog/raspberry-pi-gpio-en-franais)

From what i understand i have two available ports that support PWM but i've noticed from research that primarily suggests that GPIO 18 is the only usable PWM output.

Now forgive me for being ignorant, but my understanding from the wiring diagram concludes that i use this topology:

enter image description here

Now the servo motor will be needed to controlled in real time (Hardware PWM) as the solenoid I dont mind having a slight delay (I assume software PWM). (Please note the power will be supplied by an external source)

If anything i'm primarily writing the control code in python, but can anyone recommend a library to use for this application or at least point me in the right direction as i'm struggling to get over this coding/wiring block (Its my first time using the pi).

1 Answer 1


I doubt you'll need to use the PWM capability of gpio 18.

There are many ways to provide hardware timed PWM on the Pi on all the user gpios. They are all variations on a theme and use DMA transfers paced by the PWM or PCM peripherals.

You can ignore that as they are all wrapped up in simple wrappers.

My offering is pigpio which will let you send servo/PWM pulses from C, Python, or the command line (via the pigs utility).

  • Well i would upvote your answer but unfortunately i don't have a high enough rep, but one question i do have is why wouldn't i need to use the gpio 18 port for servo motor control, I'm guessing you can change some of the gpio ports for software pwm instead of using hardware pwm controlled ports?
    – Pariah
    Sep 3, 2014 at 13:55
  • 2
    gpio18 has support for specialised types of PWM (audio features) which are not required by servos/motors/LEDs which just need repetitive timed pulses. pigpio uses the DMA peripheral to send timed repetitive pulses to the gpios without software involvement. It's not subject to the jitter you get from timing the pulses in software.
    – joan
    Sep 3, 2014 at 14:16
  • Ah you are right, I've been reading some of the documentation, and yes ill defiantly keep that in mind sorry for the very inane questions, and thank-you for your help
    – Pariah
    Sep 3, 2014 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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