Hey guys, I got a Qwiic motor driver kit a while ago, as well as the jetbot frame. I assembled the jetbot frame, attached the motor, and wired them to the qwiic motor driver. My only problem is that the robot veers to the left, but my code says that both motors should be going at speed 255.
Here is my code:
#include <Arduino.h>
#include <stdint.h>
#include “SCMD.h”
#include “SCMD_config.h” //Contains #defines for common SCMD register names and values
#include “Wire.h”
SCMD myMotorDriver; //This creates the main object of one motor driver and connected peripherals.
void setup()
{
pinMode(8, INPUT_PULLUP); //Use to halt motor movement (ground)
Serial.begin(9600);
Serial.println(“Starting sketch.”);
//***** Configure the Motor Driver’s Settings *****//
// .commInter face is I2C_MODE
myMotorDriver.settings.commInterface = I2C_MODE;
// set address if I2C configuration selected with the config jumpers
myMotorDriver.settings.I2CAddress = 0x5D; //config pattern is “1000” (default) on board for address 0x5D
// set chip select if SPI selected with the config jumpers
myMotorDriver.settings.chipSelectPin = 10;
//initialize the driver get wait for idle//
while ( myMotorDriver.begin() != 0xA9 ) //Wait until a valid ID word is returned
{
Serial.println( “ID mismatch, trying again” );
delay(500);
}
Serial.println( “ID matches 0xA9” );
// Check to make sure the driver is done looking for peripherals before beginning
Serial.print(“Waiting for enumeration…”);
while ( myMotorDriver.ready() == false );
Serial.println(“Done.”);
Serial.println();
//Set application settings and enable driver//
//Uncomment code for motor 0 inversion
//while( myMotorDriver.busy() );
//myMotorDriver.inversionMode(0, 1); //invert motor 0
while ( myMotorDriver.busy() );
myMotorDriver.enable(); //Enables the output driver hardware
}
#define LEFT_MOTOR 0
#define RIGHT_MOTOR 1
void loop()
{
myMotorDriver.setDrive(LEFT_MOTOR,0,255);
myMotorDriver.setDrive(RIGHT_MOTOR,0,255);
}