Introduction: Arduino Grove I2C Motor Driver

About: My team has developed a new product. PLEASE CHECK IT OUT ON INDIEGOGO AND SHOW YOUR SUPPORT. CAMPAIGN LINK: https://igg.me/p/2165733/x/17027489. I'm a tech and food enthusiast and also a Soccer Player. I love…

I2C is a serial protocol for two-wire interface to connect low-speed devices like microcontrollers, EEPROMs, A/D and D/A converters, I/O interfaces and other similar peripherals in embedded systems. It was invented by Philips and now it is used by almost all major IC manufacturers. One of the applications of I2C is it's use in Motor Drivers.

In this Instructable, I'll show you how to control DC Motors using the Grove I2C Motor Driver with Arduino.

Step 1: Components Required

For this simple project, you'll need:

  • Arduino Uno.
  • Grove Base Shield.
  • Grove I2C Motor Driver
  • Connecting Wires.
  • DC Motors.
  • 9V Battery.

Step 2: About the Grove Base Shield

The Grove shield is basically an adapter to the Arduino which plugs into the latter and maps each and every I/O pins of the Arduino to specific ports on the shield designed for a specific function. If you examine closely, the shield will have dedicated ports for I2C(Controlling Motors), Analog Ports and Digital Ports. This is very helpful for beginners who are learning Arduino. In a nutshell, it makes it easy for the user to plug in the sensors on to the Arduino and start using them right away.

If you have a Grove Kit, you will notice that they come with all the sensors specifically designed for the Base Shield. But you can use other sensors also with the shield. In the same way, you can use the grove modules directly with Arduino or any micro-controller.

Step 3: About Grove Motor Driver

The Grove - I2C Motor Driver can directly control Stepper Motor or DC Motor. Its heart is a dual channel H-bridge driver chip(L298N)that can handle current up to 2A per channel, controlled by an Atmel ATmega8L which handles the I2C communication with platforms such as Arduino. Both motors can be driven simultaneously while set to a different speed and direction. It can power two brushed DC motors or one 4-wire two-phase stepper motor. It requires a 6V to 15V power supply to power the motor and has an onboard 5V voltage regulator which can power the I2C bus and the Arduino(selectable by jumper). All driver lines are protected by diodes from back-EMF.

Step 4: Connections

  1. Plug in the Grove Base Shield on the Arduino.
  2. Follow the picture and connect the DC Motors to the Grove I2C Motor Driver. Also connect a Battery with appropriate capacity as per requirements by the Motors.
  3. You can power the Arduino directly from the I2C board, but I wouldn't suggest it as it would be a waste of battery.

Step 5: Code

#include "Grove_I2C_Motor_Driver.h"

// default I2C address is 0x0f #define I2C_ADDRESS 0x0f

void setup() { Motor.begin(I2C_ADDRESS); }

void loop() { // Set speed of MOTOR1, Clockwise, speed: -100~100 Motor.speed(MOTOR1, 50); // Set speed of MOTOR2, Anticlockwise Motor.speed(MOTOR2, -70); delay(2000); // Change speed and direction of MOTOR1 Motor.speed(MOTOR1, -100); // Change speed and direction of MOTOR2 Motor.speed(MOTOR2, 100); delay(2000); // Stop MOTOR1 and MOTOR2 Motor.stop(MOTOR1); Motor.stop(MOTOR2); delay(2000); }

Step 6: The Output

If you've uploaded the code I've given in the previous step, then you will be able to see the motors turn in one direction with some speed and after 2 second delay, it'll change the direction and rotate with a higher speed and so on.

You can modify the code and use it as per your requirements.

That's All Folks !! Stay Tuned For More !!


Makerspace Contest 2017

Participated in the
Makerspace Contest 2017