So the Hookup guide for SCMD is helpful, but I still haven’t got it fully working yet.
I have added in some of the code that the hookup guide has in it’s examples but whenever myMotorDriver.setDrive(0,1,255) runs, it will run the first motor on both controllers simultaneously. Same goes for myMotorDriver.setDrive(1,1,255). When I use a motor number greater than 1, nothing runs
//This example drives a robot in left and right arcs, driving in an overall wiggly course.
// It demonstrates the variable control abilities. When used with a RedBot chassis,
// each turn is about 90 degrees per drive.
//
// Pin 8 can be grounded to disable motor movement, for debugging.
#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;
delay(2500);
// initialize the driver and enable the motor outputs
uint8_t tempReturnValue = myMotorDriver.begin();
while ( tempReturnValue != 0xA9 )
{
Serial.print( “ID mismatch, read as 0x” );
Serial.println( tempReturnValue, HEX );
delay(500);
tempReturnValue = myMotorDriver.begin();
}
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();
// Report number of peripherals found
uint8_t tempAddr = myMotorDriver.readRegister(SCMD_SLV_TOP_ADDR);
if ( tempAddr >= START_SLAVE_ADDR )
{
Serial.print("Detected ");
Serial.print(tempAddr - START_SLAVE_ADDR + 1); //Top address minus bottom address + 1 = number of peripherals
Serial.println(" peripherals.");
}
else
{
Serial.println(“No peripherals detected”);
}
while ( myMotorDriver.busy() );
myMotorDriver.enable(); //Enables the output driver hardware
}
void loop()
{
Serial.println(“Now stepping through the motors.”);
for (int i = 0; i < 6; i++)
{
Serial.print("Driving motor ");
Serial.println(i);
myMotorDriver.setDrive( i, 1, 255); //Drive motor i forward at full speed
delay(1000);
myMotorDriver.setDrive( i, 0, 255); //Drive motor i backward at full speed
delay(1000);
myMotorDriver.setDrive( i, 1, 0);
}
}