dead reckoning

can someone tell me how to do the deadreckoning code??

If you want it in the simplest form. Just make a counter. Then say start with state 1, after x number goto state 2, then x number state 3. By state I mean pwm and relay outputs.