_delay vs delay


#1

I notice in the default code for the mbot Ranger it uses this function for delaying the program:

void _delay(float seconds) {
if(seconds < 0.0){
seconds = 0.0;
}
long endTime = millis() + seconds * 1000;
while(millis() < endTime) _loop();
}

How is that different from using the normal C programming “delay()” function? Does it matter which I use?

The other question is if I set the ranger to move forward at a certain speed as follows:

Encoder_1.setTarPWM(-moveSpeed);
Encoder_2.setTarPWM(moveSpeed);

and then issue a delay, does the ranger stop moving for the duration of the delay or does the program delay while the ranger keeps moving forward?


#2

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.