How exactly can I implement my formula to calculate distance into my autonomous code? I want the robot to move forward while the distance is greater than a certain number. If I use a while loop the rc crashes and does nothing. This is the code I have so far:
Quote:
while (autonomous_mode || p3_sw_trig == 1) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
// Start autonomous code
// call camera functions
Servo_Track();
Camera_Handler();
Tracking_Info_Terminal();
if (Get_Tracking_State() == CAMERA_ON_TARGET)
{
pwm13 = pwm14 = 104;
pwm15 = pwm16 = 150;
}
else if (Get_Tracking_State() == SEARCHING)
{
pwm13 = pwm14 = 150;
pwm15 = pwm16 = 104;
}
// End autonomous code
PWM(pwm13,pwm14,pwm15,pwm16);
Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
}
}
|
How can I build my code around this?