Raspberry Pi – How to control motors…

In this tutorial I show you how to control a motor with your Raspberry Pi. By the end of this tutorial you will be able to control the direction of the motor, you will understand the basic principles of how that motor works and you will be able to decipher a simple Python program. Personally I think that controlling motors is one of the coolest things that you can do with the Pi and I truly hope that you enjoy this tutorial! Sorry for the long delay in between videos!

Information:

Buy a motor similar to my one from here: http://www.ebay.co.uk/itm/Arduino-Smart-Car-Robot-DC-3V-6V-Drive-Gear-Motor-with-tire-/161071687657?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item25809ee7e9

Buy a battery pack similar to my one from here: http://www.ebay.co.uk/itm/1-2-3-4-6-8-x-AA-AAA-23A-9V-Battery-Holder-Snap-On-Connector-Enclosed-Box-Switch-/180814661762?pt=UK_BOI_Electrical_Components_Supplies_ET&var=&hash=item2a1964c882

Buy an L298N from this link here: http://www.ebay.co.uk/itm/L298N-Dual-H-Bridge-Stepper-Motor-Driver-Controller-Board-Module-Arduino-Ra-Pi-/130968976501?pt=UK_BOI_Industrial_Automation_Control_ET&hash=item1e7e5bfc75

Wires are easily available on eBay as well!

All of the code and information is in this forum post here: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=37&t=55288

Thanks for watching and please subscribe, like and comment!

Happy Piing!

The Raspberry Pi Guy

Y U NO SUBSCRIBE?!

Duration : 0:18:13


Related Reading:

Uncategorized

Be Sociable, Share!

25 thoughts on “Raspberry Pi – How to control motors…

  1. Most of all videos …
    Most of all videos I’ve seen, the user is pi, with the stupiest sudo setup
    that I know…
    Plus: all of you using the xserver. So much Ressources for a mouse.

    Y U NO use the power of shell??

  2. Good explanation.

    Good explanation.

    I have one question for which I believe other people may have too:

    How to control speed of the motor(s)?

    This is because sometimes we don’t need our robot to run as faster as
    possible, but instead very slowly – especially when some detector
    (ultrasound) is attached to help avoid obstacles. If speed is too fast,
    then robot will bump into obstacles too often.

    Than you in advance,
    milan
    —?

  3. so you made it …
    so you made it control a wheel but how would you get it to control multiple
    wheels??

  4. Is it possible to …
    Is it possible to control any type of motor with a raspberry pi or arduino?
    I would like to use the actual claw machine from a real arcade machine,
    would I be able to control the motors on the claw gantry(x-y)? They look
    like dc motors. ?

  5. Thanks again. Just …
    Thanks again. Just spent time with my daughter converting a small robot
    using this. We used two wheels (easy enough) and, other than being a little
    under-powered, it worked great.

    I didn’t want to have anything connected such as a keyboard so I set up SSH
    so that I could remote into the Pi and run the programs using Putty from my
    Android tablet. Look ma! No hands!?

  6. Nice tutorial! That …
    Nice tutorial! That exactly what I need. But I tried and found the rpi
    can’t work however. When it started screen can print some messages,
    Particularly the network module can’t work, neither wired or wireness. And
    the power I use is 12V. So I doubt the gpio 5V if whether can as the power
    input? I also see the circult diagram, it didn’t has a diode, then I can’t
    how to do next, appreciate for any advices.?

  7. I get a syntax …
    I get a syntax error (Non-ASCII character) on line 13 :L when I run the
    code.?

  8. great tutorial, I …
    great tutorial, I don’t think it was to long, just nice and slowly…..?

  9. I’m doing a project …
    I’m doing a project in school where I want to be able to use the Pi to
    unlock a locker in some way. Is it possible to do this using a L298N? I’m
    completely new to programming.?

  10. Can you control …
    Can you control motor speed with the L298N or is it just an on and off
    function???

  11. Hi RaspberryPiGuy, …
    Hi RaspberryPiGuy, first of all thanks for great tutorial vidoes.
    Regarding the L298N, I might have to mention, that maybe you can point out
    that the “5V enable” jumper must be taken off in order to take out the risk
    of pulling more than 16mA from the Pi.
    -I think I have just burned off one of my GPIO pins
    -mine was GPIO 4 used for the ENA
    -now it simpy cuts off after a few seconds

    Furthermore, I can’t seem to pin out why you use two GPIO pins for both ENA
    and ENB, would one not be sufficient??

  12. Awesome – I am off …
    Awesome – I am off to Maplin. Lets see if I can get my Lego Motors to run.
    As Mindstorms is way too expensive?

  13. Would it be easier …
    Would it be easier and/or more efficient to control motors that
    are connected to arduino but controlled by raspberry pi. I’ve already
    successfully done this but I was wondering if excluding arduino and only
    using RPi would be more beneficial. I’m working on converting a RC car into
    a car that will connect via wifi to be controlled by inputs on my computer
    and receive a live camera feed and later I plan on making the car
    autonomous by adding sensors.?

  14. I have a robot that …
    I have a robot that has 2 6V motors (pololu.com/catalog/product/1060) and
    would like to achieve what you did in this video. I will be using a
    raspberry Pi. Can you recommend a servo board that I can use? Or will the
    one in the video be enough to power both the motors that I have?

Leave a Reply