The TB6612FNG Dual Motor Driver Carrier (https://www.pololu.com/product/713) allows you to drive a pair of small brushed DC motors. This type of motor driver is known as a full H-bridge motor driver. This driver can accept input voltage ranges from 4.5V to 13.5V to drive DC motors, and the logic supply voltage can be 2V to 7V.
A 1×16-pin breakaway 0.1″ male header strip is included with the TB6612FNG motor driver carrier. You can find more details about the breakaway male header at https://www.pololu.com/product/965. This strip can be soldered to the carrier board so that it can be used with solderless breadboards.
Once soldered, you can use it with a solderless breadboard. You can choose a breadboard to fit the size and shape of your robot chassis. Some breadboards offer mounting options, so you can easily mount them using standoffs. Pololu offers a wide array of breadboards (https://www.pololu.com/category/28/solderless-breadboards).
The following diagram shows the top view of the board with pads labeled:
The following table shows the functions of each connection pad:
Pin | I/O | Function |
AO1 |
O
|
Connect with left motor |
AO2 | ||
BO1 |
O
|
Connect with right motor |
BO2 | ||
PWMA |
I
|
Connect with Raspberry Pi |
AIN2 | ||
AIN1 | ||
BIN1 |
I
|
Connect with Raspberry Pi |
BIN2 | ||
PWMB | ||
VCC |
-
|
Small signal supply connect with Raspberry Pi 5V pin |
VMOT |
-
|
Power supply for motors. 2.5V to 13.5V DC from a battery pack. |
GND |
-
|
Power ground |
Motors should be directly connected with the motor driver. The connection between the motor driver and the Raspberry Pi handles the control signal:
- Connecting motors:
- Connect the wires coming from the left motor to AO1 and AO2
- Connect the wires coming from the right motor to BO1 and BO2
- Connecting battery pack
- Connect the battery pack to VMOT and GND
- Connecting Raspberry Pi
- Connect VCC to the Raspberry Pi 5V
- To control the left motor, connect:
- AIN1 to GPIO 4
- AIN2 to GPIO 5
- PWMA to GPIO 6
- To control the right motor, connect:
- BIN1 to GPIO 27
- BIN2 to GPIO 28
- PWMB to GPIO 29
- Connect STBY to the Raspberry Pi 5V
The following screenshot shows the pinout of the Raspberry Pi GPIO header. WiringPi and BCM use different pin number assignments. The C++ code you will be writing uses WiringPi notation for the pin numbering:
The following table shows the control signal for each mode of two motors. You can use Clock Wise (CW), Counter Clock Wise (CCW), and stop modes to control the motors:
Listing 8.1 (https://github.com/PacktPublishing/Hands-On-Internet-of-Things-with-Blynk/blob/master/Chapter%208/Listing%208-1/main.cpp) shows the C++ code that you can use to run on the Raspberry Pi to control the two motors according to the signal coming from the Blynk app:
Listing 8.1: Robot vehicle control code
Refer to the following steps:
- Open main.cpp and replace the existing code with the Listing 8.1. Then, build the project again.
- Finally, run the project with the auth token.
- Tap the play button in the Blynk app builder to run the controller application:
- Tap each button to move the robot vehicle.