Programing delays in MPLAB

Yeah. What is the command to set up a delay (like go forward for x seconds) ?

There is no single function through MPLAB, but there are several ways to accomplish what you want. The simplest is to just use a count of the slow radio packet loops as an approximation of time.
Here’s an example.


#define HOW_LONG 38                //38 = 1 second, e.g., 76 = 2 seconds
static int counter=0;
 
if (counter < HOW_LONG)
{
    counter++;
    // Drive at half speed
    pwm01 = 127 - 60;
    pwm02 = 127 + 60;
}
else
{
    // Stop driving
    pwm01 = 127;
    pwm02 = 127;
}

Another method is to setup an internal clock, but that’s more complex.
There’s a white paper on understanding timers here: http://www.ifirobotics.com/docs/timers_white_paper_2004-jan-14.pdf