Update: Can I possibly use the TLC5940 to control two motors?

So there is a lot of talk about controlling two motors.

My plan is two build a RPi robot and at minimum I need to have it control alteast two motors. I don't care about the speed too much.

Adafruit's has a nice tutorial about controlling a motor with the l293D IC. They also mention it can control two motors but I would need another PWM output from the PI.

I'm still a newbie here but what is the easiest way to get this done? Is there any other bridge or part I can buy that'll help me out?

In the end I hope to be able to control the sparkfun rover 5 platform, any pointers to this direction would be extremely appreciated.

  • If you don't care about speed, you don't need PWM at all. Commented Jun 23, 2013 at 20:15
  • Note you may be able to use the same PWM for both motors, if you are willing to always run them at the same magnitude of speed and only enable/reverse them independently. However, that would not provide the full range of smooth steering options. Offloading to a helper devices like a minimal Arduino might be worth looking into, too. Commented Jan 28, 2014 at 17:53

2 Answers 2


I am currenting trying to do a similar thing. I plan on controlling my robot with 2 motors and a servo without adding any additional hardware pwm pins. I will be using the hardware pwm pin to control the servo due to its precise requirements however the two DC motors will be controller by software pwm.

I have yet to implement this so i cant tell you the exact code however the WiringPi module provides the ability to use almost any gpio port as a pwm output. I suggest using the L293D along with a breadboard to start with for ease of modification to your wiring. Each DC motor will require 3 ports i believe 2 to provide high and low signals which control the motor directon and the other the pwm input to control the speed. Along with the control wires should be an external power supply as the pi will struggle to power any serious motors, these connections will use up the final 2 connections on the L293D.


Please feel free to let me know how it goes as i am rather busy at the moment and wont be able to get round to doing the actual contruction of my own for a little while and would love to be told exactly how to do it :P


to control more than 2 DC motors you will need 2 L293D chips and due to the amount of GPIO pins needed to provide directional proportional control, for 4 motors you may want to consider a GPIO extension board. Some of these even include extra hardware PWM options! But of course add to the overall size and cost fo your robot.

edit 2

Having now got this to work, albeit with only one of the motors using pwm and the other simply running on full (the remote control car frame i got cheap from a car boot happens to use this method rather than running a servo to steer? weird aye.) to see the wiring diagram for what i did go to


The only variation is that you would need to change wire from enable 2 to the 5v on the pi to any of the spare numbered ports. Then some wiring pi code (assuming you have followed the method described on the website to install it.

import wiringpi2
wiringpi2.wiringPiSetupSys #set up the pin numbering to match pi cobbler style
wiringpi2.pwmWrite (int pin, int value) #set the pin and value using this    

For anything with PWM I would recommend the PIGPIO module. I haven't used a chip, as I use RC motors with Electronic speed controllers, but I don't see why it shouldn't work in the same way.


PIGPIO is an incredibly flexible C library. Use the built in gpioPWM(pin,value) function. This can be used to send PWM down any of the Pi's GPIO, which is very flexible.

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.