Gravity:IO Expansion & Motor Driver Shield V1.1 SKU: DFR0502

From DFRobot Electronic Product Wiki and Tutorial: Arduino and Robot

Category.png Home > Arduino > Arduino Shields

Category.png Home > Sensors & Modules > Motors & Actuators & Drivers > DC Motor Driver


Gravity IO Expansion Shield with Motor Driver is a new product designed for Arduino Boards. It combines IO Expansion Shield and DC Motor Driver Shield, equipped with Gravity sensor interface and TB6612FNG dual motor driver. It also has XBee socket, I2C interface and UART port, makes the connections more convenient.

With TB6612FNG dual channel motor driver IC, the shield can drive 2x1.2A DC motors at the same time. It supports PWM speed control, each channel can output 1.2A continuous current and the peak current can reach to 3.2A. It is compatible with majority micro DC motors in the market. It is a solid choice for small intelligent robot controls, convenient and cost-effective.


  • Compatible with Arduino UNO R3 Pinmap.
  • Gravity-3Pin interface, plug & play, esay to use.
  • Integrated XBee Slot, XBee, WiFi Bee, Bluetooth Bee compatible.
  • Program download switch will avoid serial occupancy during Arduino UNO/Mega downloading.
  • 2x1.2A TB6612FNG DC motor driver (power from Vin port).


  • Digital interface: 14
  • Analog interface: 6
  • IIC interface: 2
  • SPI interface (compatible with Arduino UNO R3): 2
  • Serial port: 1
  • XBee Slot: 1
  • Output Current: 1.2A single channel continuous driving current
  • Start/ Peak Current: 2A (continuous pulse)/ 3.2A (monopoles)
  • Input Voltage: 12V (peak value)
  • Occupying Pins: D4, D5, D6, D7 (caution: the pin is occupied when control the motor)
  • Size: 68.5mm×53.3mm (2.7 inch×2.1 inch)
  • Weight: 36

Board Overview

Num Description
1 Digital interfaces
2 XBee interfaces
3 Analog interfaces
4 Power supply and reset interfaces
5 dual channel motor driving interfaces
6 SPI interfaces
7 Serial port interfaces
8 Programming switch (RUN: Running XBee; PROG: Sketch upload)
9 State indicators
10 IIC interfaces

Detail Explanation


Here is an onboard LED in the expansion shield, it is connected to digital pin 13.


Letter ’D’ and ‘A’ are printed in the Gravity: IO Expansion & Motor Driver Shield
DFR0502 BOARD 2 74px-Aicon D.PNG
‘D’: stands for digital signal, which should be connected to digital pins.
DFR0502 BOARD 2 74px-Aicon A.PNG
‘A’: stands for analog signal, which should be connected to analog pins.

Gravity: IO Expansion & Motor Driver Shield V1.0 is sufficient in interfaces. Compared to limited power supply interfaces in the control shields, it equipped with more GND interfaces and power supply interfaces. Although a multi-sensors connection, no need to worry about interface shortage.

A row of red pins and a row of black pins are below digital pins and analog pin.  They are the expanding power supply interface. The red pins connect to the power supply (VCC) and the black pins connect to GND.

DFRobot Colors Explanation
  • Green:

    Digital Signal
  • Blue:

    Analog Signal
  • Red:

  • Black:

DFR0502 BOARD 2 400px-Sensor des 2.png

The reason why designed the order as Signal > VCC > GND is to correspond to sensors linear order, the design has improved the wiring efficiency.


The new expansion shield added switch ‘RUN’ and ‘Download’. When using controller such as Arduino UNO/ Mega, you may failed to download program because downloading and XBee would occupy the same serial port. Therefore, you should switch to ‘PROG’ in download and switch to ‘RUN’ in run.

Sample Code

  * file motor.ino
  * brief Show Show The motor turns clockwise or counterclockwise.  
  * Copyright  [DFRobot](
  * Copyright GNU Lesser General Public License  *
  * @author [DongZi](
  * version  V1.0
  * date  2017-07-05

void setup() {
pinMode(4,OUTPUT);   /* define  pin (4,5,6,7) out*/
void motor_c(char motor_n,char direction_m,int speed_m ) /* motor_n: the motor number to drive(0 stands for M1;1 stands for M2)*/
/* direction_m : the motor rotary direction(0 is clockwise and 1 is counter-clockwise).*/
/* speed_m: to control the motor rotation speed(from 0 to 255 ), the speed_m value is larger, the rotation speed is faster;*/
{  if(motor_n==1) 
   {   if(direction_m==1) 
        {digitalWrite(4,HIGH);    // pin 4 controls M2 rotary direction analogWrite(5,speed_m);  //pin 5 controls M2 rotation speed
        {digitalWrite(7,HIGH);  // pin 7 controls M1 rotary direction
         analogWrite(6,speed_m);//pin 6 controls M2 rotation speed 
void loop() {
 motor_c( 0,0,127 );// M1 rotate in clockwise of 127 component velocity(total as 225) 
 motor_c( 1,0,127 );// M1 rotate in clockwise of 127 component velocity(total as 225) 
 delay(5000);        //delay for 5s
 motor_c( 0,1,200 );// M1 rotate in counter-clockwise of 200 component velocity(total as 225)  
 motor_c( 1,1,200 );// M2 rotate in counter-clockwise of 200 component velocity(total as 225) 
 delay(5000);      //delay for 5s

D.C Motor Driving Effect

DFR0502 AP 1D.C Motor Driving Effect.jpg


The motor rotate slowly in clockwise for 5s and rotate quickly in counter-clockwise for 5s and goes on.

NOTE: If the motor rotating direction is opposite to the expectation, you just need to adjust the pin order.


For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents

DFshopping car1.png Get Gravity: IO Expansion & Motor Driver Shield from DFRobot Store or DFRobot Distributor.