Okay, I removed exitSafeStart(); from
{
mySerial.begin(19200);
delay(5);
mySerial.print(0xAA, BYTE);
exitSafeStart();
}
And that fixed that issue. Was that the wrong thing to do? I am not sure what function that line was doing. This is the code so far that completes the verifying without errors. Do you see anything that stands out to you? At this point in time I'm only guessing on what some of these lines of code are doing.
#include <NewSoftSerial.h>
#define rxPin 3 // pin 3 connects to SMC TX (not used in this example)
#define txPin 4 // pin 4 connects to SMC RX
NewSoftSerial mySerial = NewSoftSerial(rxPin, txPin);
// pululu codes
#define NEWCMD 0xAA
#define EXITSAFESTART 0x03
#define FORWARD 0x05
#define REVERSE 0x06
// device id's
uint8_t Motor1 = 10;
uint8_t Motor2 = 13;
void exitSafeStart(uint8_t device)
{
mySerial.print(NEWCMD, BYTE);
mySerial.print(device, BYTE);
mySerial.print(EXITSAFESTART, BYTE);
}
void setMotorSpeed(uint8_t device, int speed)
{
mySerial.print(NEWCMD, BYTE);
mySerial.print(device, BYTE);
if (speed < 0)
{
mySerial.print(REVERSE, BYTE); // motor reverse command
speed = -speed; // make speed positive
}
else
{
mySerial.print(FORWARD, BYTE); // motor forward command
}
speed = constrain(speed, 0, 3200); // speed should be a number between 0 to 3200
mySerial.print((unsigned char)(speed & 0x1F), BYTE);
mySerial.print((unsigned char)(speed >> 5), BYTE);
}
void setup()
{
mySerial.begin(19200);
delay(5);
mySerial.print(0xAA, BYTE);
}
void loop()
{
//int speed = analogRead(A0) * 6 - 3072; // use an LDR or potmeter or ...
setMotorSpeed(Motor1, 3200); // full-speed forward
delay(1000);
// int speed = analogRead(A1) * 6 - 3072;
setMotorSpeed(Motor2, -3200); // full-speed reverse
delay(1000);
}