Hello, I am having an issue with my code. I have a mobile robot and a webcam to search for an object, the robot centers itself to the object and moves forward to some amount. However, what the codes does is run the functions pan() and move(), at the same time. I would like it to run the pan() for some amount than move() for some other amount. I am not sure where to begin, I've read a few on the millis() and tried it out but it still didn't help. Any help would be appreciated. I posted my loop to show where I would like this to happen.
void loop()
{
readNextByte();
//============================================================================
// Servo/Motor Control Algorithms
//============================================================================
// Print back parsed data
if(count == 3)
{
for (int i = 0; i < 3; i++)
{
Serial.print(command[i]);Serial.print(var[i]);Serial.print(' ');
}
// Pan servo algorithm
pan();
move();
}
}
However, what the codes does is run the functions pan() and move(), at the same time.
No, it doesn't. The Arduino can only do one thing at a time. If pan() starts some motor(s) turning, and then ends, and move() starts some motor(s) turning, and then ends, it will appear that both things are happening at the same time, but they did not.
Without seeing your pan() and move() functions, we're just guessing at how to help you.