Skip to main content

Grove - I2C Motor Driver (L298P)

Grove - I2C Motor Driver(L298P) is a common-use motor driver for stepping motor and servo motor. It embeds an STM32 chip for burning the code to control the motor driver. This is a 2-channel motor driver, each channel can support up to 1A current. You can also use the I2C interface to transmit data from the peripheral microcontroller. The default I2C address is 0x0f and you are able to change the address of Motor driver by connecting the I2C wire hat. The I2C address is selectable from 0x00 to 0X0f.

Features

  • MCU: STM32f030f4P6 microcontroller for burning the code and control the Motor Driver.
  • L298P Motor driver chip: common use for a motor driver and can drive stepping motor and servo motor.
  • Selectable I2C address: change the connection of wire hat to get the I2C address from 0x00 to 0x0f, the default I2C address is 0x0f.
  • 2-channel output: able to support 1A current on each channel, max 2A current; Need 6V-12V DC voltage input.
  • User LED: green LED on for the clockwise direction and red LED on for the anti-clockwise direction for each channel.

Specification

ItemValue
MCUSTM32f030f4P6
Power Supply6-12V DC
InterfaceGrove I2C
I2C addressDefault 0x0f, can be changed by connecting the wire hat
Channel2
Output currentMAX 2A, 1A for each channel
Output voltage5V

Platform Supported

ArduinoRaspberry Pi

Getting Started

Use Arduino platform

Materials Requied

Seeeduino V4.2Base ShieldGrove - I2C Motor Driver (L298P)
enter image description hereenter image description hereenter image description here
Get One NowGet One NowGet One Now

Hardware connection

  • Step 1 Connect Grove - I2C Motor Driver (L298P) to port I2C of Grove-Base Shield.

  • Step 2 Plug Grove - Base Shield into Seeeduino.

  • Step 3 Connect Seeeduino to PC via a USB cable.

Software Code 1 - DC Motor

#include "Grove_I2C_Motor_Driver.h"

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

void setup() {
Serial.begin(9600);
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);
}

With speed() function, you are able to drive one motor at the speed you want.

  • motor_id represents which motor to use. You can fill MOTOR1 or MOTOR2.

  • _speed represents the speed you set to the motor. You can fill -100~100 here. When _speed>0, DC motor runs clockwise, while_speed<0, DC motor runs anticlockwise. And the bigger the absolute value of _speed, the faster the speed of DC motor.

With stop() function, you are able to stop a running DC motor.

  • motor_id represents which motor to use. You can fill MOTOR1 or MOTOR2.

Software Code 2 - Stepper Motor

#include <Grove_I2C_Motor_Driver.h>

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


void setup() {
Serial.begin(9600);
Motor.begin(I2C_ADDRESS);
// Drive a stepper motor
// _step: -1024~1024, when _step>0, stepper motor runs clockwise; _step<0, stepper
// motor runs anticlockwise; when _step is 512, the stepper motor will run a complete
// turn; if step is 1024, the stepper motor will run 2 turns.
Motor.StepperRun(-1024);
Motor.StepperRun(512);
}

void loop() {

}

Take 24BYJ48 Stepper Motor as an example, The hardware installation as shown below:

The connection between 24BYJ48 Stepper Motor and I2C Motor Driver is as shown below:

  • _step represents the steps you set to the stepper motor to run. You can fill -1024~1024. When _step>0, stepper motor runs clockwise, while_step<0, stepper motor runs anticlockwise. When _step is 512/-512, the stepper motor will run a complete turn and if_step is 1024/-1024, the stepper motor will run 2 turns. The stepper motor will stop automatically after it finishes its steps.

Schematic Online Viewer

Resources

Tech Support

if you have any technical issue. submit the issue into our forum.


Loading Comments...