I see that adafruit has a tutorial running one dc motor on pin 18 with L293D and I have done this sucessfully.

My goal is to run two DC motors without adding additional hardware, I see pin 21 is also capable of PWM. Am I able to run two motors at the same time using pins 18 and 21?

  • I can't work out what you mean by pin 18 or pin 21. Which Pi model are you using? – joan Dec 10 '14 at 8:40
  • I meant RpiB rev1, and GPIO 18 and 21. I could have swore I saw a graphic that showed GPIO 21 is also PWM able but can't seem to find it now. So with my board only 1 hardware capable pinout -GPIO 18? – user1117057 Dec 11 '14 at 14:15
  • Broadcom gpios 12, 13, 18, 19, 40, 41, 45, 52, 53 support hardware PWM. Only gpio 18 is available on a Rev.1 B. However there are plenty of software modules which provide hardware timed PWM on all the gpios. E.g. my pigpio, servoblaster, pi-blaster etc. – joan Dec 11 '14 at 14:41

The Pi model B revisions 1 and 2 only exposes one gpio with hardware PWM support (gpio 18 on pin 12 of the expansion header).

The Pi models A+ and B+ expose gpios 12, 13, 18, and 19 with hardware PWM support. There are only two PWM channels though so you still only have two hardware PWM settings to choose from rather than 4.

However PWM suitable for driving motors may be generated by software on all gpios using either software or hardware timing of the pulses.

So the answer to your question is yes, you can control two motors (with PWM to allow speed control) using the Pi and a L293D.


You can control several motors on the Raspberry Pi with pi-blaster which with the help of low-level programming can turn up to 8 pins into PWM pins. In my example I am using 2 servo motors but it can be mapped to more:


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.