Hello, I have two grove - i2c motor drivers (tb6612fng) I’m connecting to an Arduino Uno Wifi Rev2 via a Grove Digital Extender. I’m having issues figuring out how to address the second motor driver. The “Grove_Motor_Driver_TB6612FNG.h” uses the default address of 0x14 and works with the example sketch. Using an i2c scanner sketch I see another i2c address of 0x21. Is it possible to control both controllers using the Grove_Motor_Driver_TB6612FNG library?
I was thinking you could define two addresses but I’m not sure if you need to initiate both or how to send commands to the two different motors on the second controller (0x21). If someone could please provide some help that would be very appreciated. Here is the example sketch lightly modified to try to control both:
#include "Grove_Motor_Driver_TB6612FNG.h"
#include <Wire.h>
MotorDriver motor;
#define I2C_ADDRESS 0x14
#define I2C_ADDRESSa 0x21
void setup()
{
// join I2C bus (I2Cdev library doesn't do this automatically)
Wire.begin();
Serial.begin(9600);
motor.init(I2C_ADDRESS);
motor.init(I2C_ADDRESSa);
}
void loop()
{
// drive 2 dc motors at speed=255, clockwise
Serial.println("run at speed=255");
motor.dcMotorRun(MOTOR_CHA, 255);
motor.dcMotorRun(MOTOR_CHB, 255);
delay(1000);
// brake
Serial.println("brake");
motor.dcMotorBrake(MOTOR_CHA);
motor.dcMotorBrake(MOTOR_CHB);
delay(1000);
// drive 2 dc motors at speed=200, anticlockwise
Serial.println("run at speed=-200");
motor.dcMotorRun(MOTOR_CHA, -200);
motor.dcMotorRun(MOTOR_CHB, -200);
delay(1000);
// stop 2 motors
Serial.println("stop");
motor.dcMotorStop(MOTOR_CHA);
motor.dcMotorStop(MOTOR_CHB);
delay(1000);
}
Thanks in advanced.