// We're going to check both motors; the logic is the same
// for each...
byte result = motor0.getFault();
// If result masked by FAULT is non-zero, we've got a fault
// condition, and we should report it.
if (result & FAULT)
{
Serial.print("Motor 0 fault: ");
if (result & OCP) Serial.println("Chip overcurrent!");
if (result & ILIMIT) Serial.println("Load current limit!");
if (result & UVLO) Serial.println("Undervoltage!");
if (result & OTS) Serial.println("Over temp!");
break; // We want to break out of the motion immediately,
// so we can stop motion in response to our fault.
}
result = motor1.getFault();
if (result & FAULT)
{
Serial.print("Motor 1 fault: ");
if (result & OCP) Serial.println("Chip overcurrent!");
if (result & ILIMIT) Serial.println("Load current limit!");
if (result & UVLO) Serial.println("Undervoltage!");
if (result & OTS) Serial.println("Over temp!");
break;
}
}
}
}
Now click Upload(CTRL+U) to burn testing code. Please refer to
you can also add comment on
Review Results
After upload completed, the motors will rotating in the positive or opposite direction in cycle.
Resources
Grove - Mini I2C Motor Driver_Eagle_File
Grove - Mini I2C Motor Driver Schematic Document
Grove - Mini I2C Motor Driver Source Library