element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Wiring a motor to the RPi?
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 63 replies
  • Subscribers 710 subscribers
  • Views 10332 views
  • Users 0 members are here
  • help
  • rc
  • pi
  • control
  • raspberry_pi
  • please
  • motor
  • raspberr
Related

Wiring a motor to the RPi?

wallarug
wallarug over 14 years ago

What do I need?

 

I am told that I need some transitors.  I have a 12v powerpack and 2 x12v motors.  How do I set this up so that I don't blow-up the RPi and that I can control the motors through the GPIO?

 

I have a gertboard on the way but I would like to see if I can do it without it first.

 

I have little knowlegde about transitors and electronics but I do know how to build circuits.

  • Sign in to reply
  • Cancel
  • wallarug
    wallarug over 13 years ago in reply to e14 Contributor

    Thanks Ken.  Great work.  I will test later

     

    What about the double H-Bridge chip in the earlier post?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to wallarug

    The schematic is for TI's L293D chip, which was posted above in a link from Adafruit.

    It is a dual H-Bridge motor driver.

     

    The E on the end of the part number is from the Eagle part library, but the pinout is the same.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • wallarug
    wallarug over 13 years ago in reply to e14 Contributor

    Thanks for informing this of that fact.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • wallarug
    wallarug over 13 years ago in reply to e14 Contributor

    Ken Seymour wrote:

     

    The schematic is for TI's L293D chip, which was posted above in a link from Adafruit.

    It is a dual H-Bridge motor driver.

     

    The E on the end of the part number is from the Eagle part library, but the pinout is the same.

    How can I get PWM working on the motors? Can you please give me instructions on software and/or extra hardware required (input device)  for PWM to work.

     

    Thanks for all your help so far.

     

    Hardware such as what gert used in his video (the slider at 3:40):

    You don't have permission to edit metadata of this video.
    Edit media
    x
    image
    Upload Preview
    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • michaelkellett
    michaelkellett over 13 years ago in reply to e14 Contributor

    @Ken

     

    There is an error in this diagram: pin 8 should be connected to 12V and pin 16 to 5V - why - because pin 16 is what ST (the chip maker) calls Vss and is the logic supply voltage and pin 8 is Vs which is the motor supply voltage.

     

     

    This circuit would be improved by changing the 100R resistors for a higher value, 2k2 would be fine and would reduce the current in the 2N2222A2N2222A transitors from 50mA to 2.3mA while still being able to pull the L293 inputs high. (They need 100uA max).

     

    Michael Kellett

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • wallarug
    wallarug over 13 years ago in reply to michaelkellett

    Just an update on what I am going to use to built this circuit:

     

    2 x 12v motors

    1 x 12v power supply (batery pack)

    1 x L293D (double H-bridge chip)     http://www.adafruit.com/datasheets/l293d.pdf  < Datasheet

    1 x ULN2003 (Darlington Transistor - instead of normal transistors) http://www.jaycar.com.au/products_uploaded/ZK8855.pdf  < Datasheet

    Whatever restiors anyone suggests (I will buy when necessary)

    Headers & PCB

    1 x Raspberry Pi

     

    Can someone let me know if anything else is required.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • wallarug
    wallarug over 13 years ago in reply to e14 Contributor

    Just an update on what I am going to use to built this circuit:

     

    2 x 12v motors

    1 x 12v power supply (batery pack)

    1 x L293D (double H-bridge chip) http://www.adafruit.com/datasheets/l293d.pdf < Datasheet

    1 x ULN2003 (Darlington Transistor - instead of normal transistors) http://www.jaycar.com.au/products_uploaded/ZK8855.pdf < Datasheet

    Whatever restiors anyone suggests (I will buy when necessary)

    Headers & PCB

    1 x Raspberry Pi

     

    Can someone let me know if anything else is required.

    I have just bought some more stuff that I though you should know:

    Just an update on what I am going to use to built this circuit:

     

    4 x 100ohm 1 Watt 5% Carbon Film Resistor - Pk. 2

    4 x 680ohm 1 Watt 5% Carbon Film Resistor - Pk. 2

    4 x 2K2ohm 1 Watt 5% Carbon Film Resistor - Pk. 2

    1 x ULN2003 Darlington transistor array IC

     

    Any of this can be used in the circuit.  If anything else is required, let me know.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago

    Sorry, I have been out of town most of the week.

     

    I have an update to the schematic to correct errors caught by Michael Kellet.

     

    He made me think about small amount of current heeded by the L239D chip.

     

    Another way to think of it is a high impeadance input.  So we don't need

     

    a lot of current gain in the transistor.

     

    While darlingtons are high current gain.

     

    The current on the chip input/transistor output will be set low by the high chip input impeadance.

     

    When you use a transistor as a switch, you set the Ib * Hfe to be larger than where the ciruit

     

    will operate in order for the transistor to alternate between cut off and saturation.

     

    So I upped the resistor values but did not set Ib * Hfe to match the current needed by the

    chip but rather to provide 10 or more times as much.

     

    The real current will by limited by the chip input impeadance and you have a low voltage

    dropped across R4/R5/R6.

     

    Ib is the transistor base current.

    Hfe is the transistor current gain.

     

    By lowering the base current, we ask the Raspberry Pi to provide less current.

     

    I drove motors with an Arduino.  It runs on 5 Volts.  It has analog inputs.  It has lots of PWM

    outputs.  It won't run Linux or Python.

     

    I have not yet tried the one PWM output on the Pi.  I don't know if a PWM driver is ready or not.

    An 8 but micro-controller normally has PWN hardware outputs.

     

    Software pwm is where you turn the GPIO output off and on and increase the speed

    by having it on a higher percentage of the time.

     

    I've thought of connecting an Arduino to the PI with 5 Volt serial or I2C and having the

    Arduino do motor control but probably not get to it.

     

    I have driven stepper motors directly of a GPIO with Darlingtons but without an H bridge chip.

     

    Any way here is the updated schenmatic in PNG. I am trying to attach the Eagle schematic.

    Attachments:
    ken2..zip
    image
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • wallarug
    wallarug over 13 years ago in reply to e14 Contributor

    How would I subsitute in a Darlington Pair into your schematic?  I have a ULN2003 Darlington IC transistor array.  See the datasheet below:  http://www.jaycar.com.au/products_uploaded/ZK8855.pdf

     

    Also, If I want to run two motors through PWM, then I would have to 'piggy back' off the circiut that is already present.  See My Schematic (experimental) based off yours below.  I think this becasue the raspberry Pi (as far as I know) only supports 1 'connection' of PWM.  Am I correct?

     

    One other thing, is the 5 volts coming out of the Raspberry Pi or an externatal source?

     

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to wallarug

    I couldn't find an Eagle part model for the darlingtons.

     

    The seen to have all the bias resistor internally.  You are not connecting them to the motor directly,

    so you don't need external diodes.

     

    So 5 Volt supply to ULN2003 pin 9. 

    Ground to ULN2003 pin 8.

    Rasberry Pi pin 7 to ULN2003 pin 1.

    Rasberry Pi pin 5 to ULN2003 pin 2.

    Rasberry Pi pin 3 to ULN2003 pin 3.

    ULN2003 pin 16 to L293D pin 1.

    ULN2003 pin 15to L293D pin 2.

    ULN2003 pin 14to L293D pin 7.

     

    You don't need the external resistors.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
<>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube