If you're planning to build a robot with an Arduino, you'll likely need a
motor shield to drive your motors! This Official Arduino Motor Shield fits right on top of your
Arduino Uno
(or compatible) microcontroller and uses a full-bridge L298 driver. The
L298 driver is capable of providing 2 channels with 5-12V at 2 amps per
channel (or 4 amps max with external power supply) to control inductive
loads such as relays, solenoids, and DC or stepper motors. It's perfect
for robotics because it is able to control the speed and direction of
two DC motors independently, as well as measure the current each motor
is using. This means that you can use your motors as an input device by
measuring changes in current flow. Did your robot just hit a wall? With
the right programming, your Arduino will sense the sudden rise of
current from the stalled motors and command your robot to reverse to
safety. The shield also features braking so you can stop your robot
quickly should the need arise.
Because the Arduino Motor Shield draws a lot of power it must be hooked up to an external 7 - 12V power supply rather than a USB connection to avoid damage. If your motors require more than 9V it is recommended that the power supply lines for the Arduino and the Motor Shield be separated and the "Vin Connect" jumper on the back of the board be cut.
Note: Standard servos will not work on this board.
Power
The Arduino Motor Shield must be powered by an external power
supply because the L298 IC mounted on the shield has two separate power
units, one for the logic and one for the motor supply driver. The
current draw for the motor supply is often than the USB can give.
External (non-USB) power can come either from
an AC-to-DC adapter (wall-wart) or battery. The adapter can be connected
by plugging a 2.1mm center-positive plug into the Arduino's board power
jack on which the motor shield is mounted or by connecting the wires
that lead the power supply to the Vin and GND screw terminals, taking
care to respect the polarities.
To avoid possible damage to the Arduino board
on which the shield is mounted, we reccomend using an external power
supply that provides a voltage between 7 and 12V. If your motor require
more than 9V we recommend that you separate the power lines of the
shield and the Arduino board on which the shield is mounted. This is
possible by cutting the "Vin Connect" jumper placed on the back side of the shield. The absolute limit for the Vin at the screw terminals is 18V.
The power pins are as follows:
- Vin on the screw terminal
block, is the input voltage to the motor connected to the shield. An
external power supply connected to this pin also provide power to the
Arduino board on which is mounted. By cutting the "Vin Connect" jumper you make this a dedicated power line for the motor.
- GND Ground on the screw terminal block.
The shield can supply 2 amperes per channel, for a total of 4 amperes maximum.
Input and Output
This shield have two separate channels, called A and B, that each use
4 of the Arduino pins to drive or sense the motor. In total there are 8
pins in use on this shield.
You can use each channel separately to drive two DC motors or combine
them to drive one unipolar stepper motor.
The shield's pins, divided by channel are shown in the table below:
| Function | pins per Ch. A | pins per Ch. B |
| Direction | D12 | D13 |
| PWM | D3 | D11 |
| Brake | D9 | D8 |
| Current Sensing | A0 | A1 |
If you don't need the Brake and in the Current
Sensing and you also need more pins for your application you can disable
this features by cutting the respective jumpers on the back side of the
shield.
The additional sockets on the shield are described as follow:
- Screw terminal to connect the motors and their power supply.
- 2 TinkerKit connectors for two Analog Inputs (in white), connected to A2 and A3.
- 2 TinkerKit connectors for two Aanlog Outputs (in orange in the middle), connected to PWM outputs on pins D5 and D6.
- 2 TinkerKit connectors for the TWI interface (in white with 4 pins), one for input and the other one for output.
Motors connections
Brushed DC motor. You can drive two Brushed DC
motors by connecting the two wires of each one in the (+) and (-) screw
terminals for each channel A and B. In this way you can control its
direction by setting HIGH or LOW the DIR A and DIR B pins, you can control the speed by varying the PWM A and PWM B duty cycle values. There are also the Brake A and Brake B
pins that if setted in HIGH state they brakes the DC motor faster than
when you power off the motor. You can know the current going through the
DC motor by reading the SNS0 and SNS1
pins. On each channel will be a voltage proportional to the measured
current, which can be read as a normal analog input, through the
functions analogRead() on the analog input A0 and A1. For your
convenience it is calibrated to be 3.3V when the channel is delivering
its maximum possible current, that is 2A.