So, I am attempting to control a DC motor using a RPi Model 2B. I am using a l293d motor driver to try to control the motor and a 4 AA battery holder. The diagram is supposed to look like this according to the site...

enter image description here

And here is a picture of how my Pi is wired...

enter image description hereenter image description here

(Sorry about the pictures)...

And the script I am using looks like the following...

import l293d.driver as l293d
motor = l293d.DC(22,18,16)
for _ in range(1,100):

The script runs successfully, but the DC motor does not do anything. Can someone please tell me why this is not working correctly. Any help is greatly appreciated. Thanks.

  • The script will complete in a small fraction of a second. How do you know nothing happens?
    – joan
    Aug 8, 2018 at 14:30
  • @jdw136 said, "Sorry about the pictures" Pictures are better than nothing, but if you're trying to show us how you've wired something they're not much help. But there's good news :) This site offers a schematic editor that's really easy to use. How do you start it? Read this
    – Seamus
    Aug 8, 2018 at 15:02
  • @joan - That was an excellent point, so I tested it by extending the script to run in an infinite loop until there was a Keyboard Interrupt, but unfortunately it still did not work.
    – jdw136
    Aug 8, 2018 at 15:14
  • 2
    The schematic shows an early 26 pin Pi whereas you are using a 40 pin Pi. Could you look at pinout.xyz and confirm the pin numbers or GPIO numbers you are using for l293d.DC(22,18,16).
    – joan
    Aug 8, 2018 at 15:21
  • @jdw136 Would it be possible to add your new script into your question (with the notation that it was written in response to comments)? Or did you just replace the for loop with a while true loop?
    – NomadMaker
    Aug 8, 2018 at 22:34

2 Answers 2


From the pictures, it looks like the chip is upside down. There's a little notch on one end that shows you where the "top" is, while you have it facing away from the top of the breadboard instead of towards it. Fortunately, based on the data sheet for the chip, this actually doesn't matter and it will function exactly the same. That's a surprise.

As pointed out in the comments, however, the pinout you're referencing is from an older version of the Raspberry Pi that has fewer pins. The pinout is backwards compatible, but you have to count from the top/right end (further from the USB ports), not the closer end as you've done. Redo those connections and you should be ok. As far as I can tell, none of these errors will have damaged your Pi.

However, in the future, I would recommend making all non-power connections to a Pi through a resistor to protect your GPIO pins from damage. In this one, for example, connect GND and 5V with wires as shown in the diagram, but replace all of the wires to GPIO with at least 100Ω (maybe even 1K or more, but less than 5K) resistors.

(Okay, obviously you would actually use a wire and a resistor, since you need the length to make the connection, but make sure there is a resistor between your circuit and your Pi. Also, this doesn't work in all scenarios, but if you're just sending digital signals between chips it's an easy way to be a little safer.)


Take a look here https://www.instructables.com/id/L293D-Motor-Driver/

Disconnect driver output - motor _ and substitute LED with limiting resistor. Make sure your DC output is off correct polarity to light the LED up. Does it light up? Can you turn it off?

If not - disconnect driver input and replace it with LED with limiting resistor. Make sure it is connected to RPi with correct polarity. Can you turn the LED on / off ?

PS Computer generated pictures are of no value if it is not actually wired correctly.

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.