Controlling A DC Motor With Arduino
In this tutorial we will be using an Arduino to control the speed and direction of a DC Motor. For this tutorial we will be using our basic DC Hobby Motor but this tutorial can be applied to just about any DC Motor out there that falls within the peak voltage and current specifications of the H-Bridge we are using. Moving forwards, this hardware and code can be adapted to make a small driving robot.
A Few Considerations:
When choosing a DC motor it will need to be compatible with the motor controller chip that we are using. This Texas Instruments SN754410NE (A popular drop in replacement for the L293D) can supply a motor with between 4.5 and 36.0V at up to 1.0A. While the motor controller can handle up to 36V, the motor we are using has a maximum voltage is 9.0VDC so to keep things simple we will want to keep the motor power supply to a voltage less than that. This voltage range gives us quite a few options – we could power it from a wall power supply, bench power supply, AA batteries, or even a 9V battery! Feel free to use which ever appropriate supply you have laying around.
How It Works:
DC motors themselves are very simple; any basic DC Motor will have two leads that can be directly attached to a battery or power supply of sufficient capacity. The side of the motor that is connected to the positive of the power source will determine which way the motor rotates. Feel free to give this a try with the breadboard and power supply! We will be going a step further than this and using a motor controller called an H-Bridge. Rather than having to unplug the motor to reverse it, this clever chip allows us to reverse the polarity to the motor using logic level signals from a microcontroller. The motor can be run in each direction on command! The chip does all of the heavy lifting and can be directly connected to the DC motor and the Arduino, no additional parts are required!
[info]Have A Question?
If you have any questions, or need further clarification please post in the comments section below; this way future users of this tutorial can see the questions and answers!