Kevin,
Ok, tried this test using Arduino Nano to Micro. It sometimes returns 0 on first loop, but then 1 immediately thereafter. I am using a gearservo, SG12 Series Servo Gearbox (5:1 Ratio, 640° Rotation, 1750 oz-in, 0.80 sec/60°) - ServoCity but wouldn’t think this would matter as it responds corrently to setTarget commands. Here’s my code and output.
// Test getMovingState
#include <PololuMaestro.h>
#include <SoftwareSerial.h>
SoftwareSerial maestroSerial(10, 11);
MicroMaestro maestro(maestroSerial);
byte c = 0;
void setup()
{
// Set the serial baud rate.
maestroSerial.begin(115200);
Serial.begin(115200);
delay(4000);
}
void loop()
{
// Set the target of channel 0 to 1500 us
Serial.println(millis());
maestro.setTarget(0, 6000);
maestro.restartScript(0);
c = 0;
while (c == 0)
{
c = maestro.getScriptStatus();
Serial.println(c);
}
Serial.println(millis());
Serial.println("-----");
delay(4000);
// Set the target of channel 0 to 7121 us
Serial.println(millis());
maestro.setTarget(0, 6000 + int(90.0F * 3.115F * 4.0F));
maestro.restartScript(0);
c = 0;
while (c == 0)
{
c = maestro.getScriptStatus();
Serial.println(c);
}
Serial.println(millis());
Serial.println("*****");
delay(4000);
}
3999
0
1
4000
-----
8001
1
8002
*****
12002
0
1
12004
-----
16004
0
1
16006
*****
20005
1
20007
-----
24007
1
24008
*****
28009
0
1
28010
-----
