Use Arduino to Control a Motor Part 2 – Motor Driver

Arduino Motor Driver

Arduino Motor Driver

Last time, we controlled the ON/OFF switch of a DC motor with Arduino. Today, I’d like to delve deeper into the use of motors.
Taking radio-controlled cars as an example, motors are used not only for turning them on and off, but also for moving forward and backward, stopping, and braking. Let’s use a motor driver to control such motors.

Today Electronic’s Recipe

Expected time to complete: 60 minutes

Parts needed:

Arduino base (Arduino Uno R3)
DC motor
Motor driver (BD6222HFP)
SOP16 pin DIP adapter board
Diode x2 (1N4007)
Resistor 10KΩ×2 / 100KΩ×2
Temperature sensor (lM61CIZ)
AA battery holder (4 in series)
AA battery×4
Toggle switch

What’s a DC Motor Driver?

Arduino motor driver

Motor driver BD6222HFP

We have here a rather small part. This is the motor driver. It can come in many different forms, but we will try out this motor driver today. A motor drivers, as the name suggests, is an integrated circuit (IC) that contains circuitry for driving (controlling) motors.

Since experience is the best teacher, let’s go ahead and fiddle with actual circuit to learn how to use the motor driver.

As you will realize when you handle the part yourself, it is considerably smaller than the parts we’ve been using until now. The terminals coming out of the IC are also narrow, and it looks like you can’t connect them directly on the breadboard.

In cases like this, we will use an adapter board to be able to convert it on the breadboard. We will place the IC atop the SOP16 pin DIP adapter board and solder it on.

The BD6222HFP that we use today has terminals only on one side of the IC, so we will only use one side of the adapter board.

SOP16 pin DIP adapter board

SOP16 pin DIP adapter board

SOP16 pin DIP adapter board

I’ll go ahead and place the IC on the adapter board and solder it on. The spaces between the pins are very narrow, so it is more difficult than the previous soldering of parts. When soldering such ICs, it is necessary to firmly secure the IC and adapter board so they do not become misaligned when the soldering iron comes in contact.

Here, I’ve secured the adapter and the IC with a clip attached to our soldering station, but if you don’t have a clip, it’s a good idea to tape the adapter board and the IC together. If you’re doing that, however, be careful that the IC doesn’t heat up and melt the tape while you’re soldering.

As for the amount of solder, you’ll need less than half of what you’d use for a usual-sized part, so if you use too much solder and connect two pins together (as I did once this time…), you can use a desoldering braid or desoldering pump to remove it.

Soldering complete!

Using the Motor Driver

Now that we’re done with soldering, we will verify the function of each pin on the motor driver from the data sheet. Despite its small size, the BD6222HFP is capable of sending 6–15v of voltage and 2A of current to the motor.

BD6222HFP data sheet

Motor Driver

VREF – Power source control for the motor (3–15v)
OUT1 – Output pin to the motor
FIN – Together with RIN, signal input for forward, backward, stop, brake, etc.
GND – Ground
RIN – Together with FIN, signal input for forward, backward, stop, brake, etc.
OUT2 – Output pin to the motor
VCC – Power source input for the motor driver (6–15v)

As we learned last time, the Arduino can’t be used as a power source for the motor. We had to add a separate battery. On the motor driver, we have separate power source input pins for the motor and for the motor driver IC.

VREF is the pin to supply power to the motor. The motor’s rotation count and such are determined by the voltage that is input here. VCC is the pin to supply power to operate the motor driver.

OUT1 and OUT2 are output pins, so we connect them to the motor. As I wrote last time, the motor can be connected without worrying about the plus/minus orientation.

FIN and RIN are the input pins for operating the motor driver. By running current of different patterns from here, we can control the motor.

Operating the Motor Using the Motor Driver

Now that we know each function, we will learn how to use them while building a simple circuit.

The circuit below is a test circuit to rotate forward and backward using the motor driver. By pressing one of the left/right switches, a signal (current) is sent from FIN or RIN to the motor driver and current flows to the motor.

Motor driver

I am using a 100KΩ resistor.

Breadboard motor driver

Controlling the Motor Driver with Arduino

Now, let’s substitute the switch parts with the Arduino. Now, we can use Arduino to control things from the program side such as stopping the motor rotation after a set time or switching the sense of rotation. The program below repeats between rotate → pause → reverse → pause every second.

Arduino with breadboard motor and motor driver

I am outputting to the motor using digitalWrite here. But since the rotation count changes based on the voltage input to the motor driver’s VREF, it is also possible to change the rotation count by using the analogWrite function instead. However, if the output is too weak and falls below 3v (the BD62222HFP is designed for 3–15v), the motor will just make a whining noise and will fail to rotate.

Desktop Fan with Temperature Sensor

By using the analog input pin, you can use the Arduino to easily accomplish things like running the motor once a sensor (such as a light sensor) reaches a certain value.

To give a simple example, by incorporating a temperature sensor, we can create a device that automatically runs a fan when the temperature rises above a certain threshold. Today, we’ll use the LM61CIZ temperature sensor. The LM61CIZ is a commonly used temperature sensor and it can measure from -30 to 100 degrees.

Arduino with breadboard motor and motor driver

Arduino with breadboard motor and motor driver

The part written in red is the conversion equation when using the LM61CIZ with the Arduino. For today, the program simply outputs to the motor when the temperature sensor’s value is greater than 25 degrees (the if statement in blue). As long as the temperature is above 25 degrees, the motor runs continuously.


Are you now comfortable with the basic operation of motor drivers? Starting next time, I’d like to incorporate motor driver functions like stop and brake to create a simple radio-controlled (RC) car with the Arduino.

If we are to build an RC car, is one motor enough? Do we need 2 motors to control steering when turning left and right? With a larger circuit, will the RC car need to be bigger, too? These are some of the questions that will come up. So next time, as we did when we worked on the Stevenson screen, we should decide on the specs of the RC car, then build and learn.