There are different approaches to driving a motor when it comes to driving a motor with Arduino. If a simple relay is used to drive a motor it can only turn the motor on and off. In case a single transistor like TIP120 (BJT) or IRF510 (MOSFE ) is used, it is possible to control the speed of the rotation. There exist smarter DC motor drivers (so called H-bridge) that can control the direction of rotation and even brake.
Seed Studio L298 Motor Driver
sketch and schematics above, compile and upload it to your Arduino. By changing the position of the potentiometer you should be able to change the rotation speed and direction of the motor.
Motor driver manual can be found here
MC33887 Motor Driver
An example of such a driver is Plolu’s MC33887 Motor Driver which is affordable and versatile. This driver can control a single DC motor with maximum consumption of 2.5A and peaks of 5A. Motor voltage can range from 5-28V which makes it an excellent general purpose motor driver.
Table below describes the marking of the pins on the back side of the MC33887 driver board from Pololu:
Interfacing MC33887 Motor Driver with Arduino
In order to drive a motor with Arduino you will need the components below:
- A DC motor (5-12V)
- A Breadboard
- A Pololu MC338870 driver board
- An Arduino with a USB cable
- Some wires
- A DC Jack connector
- An adapter matching the voltage of your motor (less than 5-12V)
- 10-50KΩ Potentiometer
Make the circuit shows below:
Your circuit should look like this:
sketch, compile and upload it to your Arduino. By changing the position of the potentiometer you should be able to change the rotation speed and direction of the motor.
The circuit suggested above is the simplest form of using an MC338870 to drive a motor. By using D1 and D2, Disable1 and Disable2, one can leave the motor pins in tri-state. FS, Fault Signal, pin can be used to determine malfunction of the driver. FB, Feed Back, can aslo be read with the analog inputs to determine the amount of current being consumed by the motors.