Salut,
has anyone had success to call sparki.motorsRotateSteps more than once in the loop?
I call it to move the robot a defined way backward. Then I call it to turn the robot for a defined angle. Both moves are fixed numbers of steps. I call sparki.motorsRotateSteps with wait=true.
The first call gets executed ok, The second one leaves the robot locked for approximately 3 seconds with no motor activity.
The complete code is:
[code]
#include <Sparki.h> // include the sparki library
void setup()
{
sparki.servo(SERVO_CENTER);
}
void loop()
{
sparki.RGB(RGB_GREEN); // turn the light green
int cm = sparki.ping(); // measures the distance with Sparki’s eyes
sparki.motorRotate( MOTOR_LEFT, DIR_CCW, 250);
sparki.motorRotate( MOTOR_RIGHT, DIR_CW, 250);
if(cm != -1) // make sure its not too close or too far
{
if(cm < 20) // if the distance measured is less than 10 centimeters
{
sparki.RGB(RGB_RED); // turn the light red
sparki.beep(); // beep!
sparki.motorsRotateSteps( DIR_CW, DIR_CCW, 250, 2600, true);
sparki.beep(); // beep!
sparki.motorsRotateSteps( DIR_CW, DIR_CW, 250, 1300, true);
sparki.beep(); // beep!
}
}
delay(100); // wait 0.1 seconds (100 milliseconds)
}[/code]
This robot is no fun…
Ciao, Mathias