so i want to put this code i got from the website http://www.rec.ri.cmu.edu/education/edubot/2004_content/index.htm
specifically the IR Reflective Sensor Program for line tracking
now in which file would i put thise code into?
although the instructiosn say to put this code into user_routines.c,
i thought you put autonomous code programming in user_routines_fast.c?
can anyone shed some light?
thanks in advance
-noob at programming :ahh:
this is the code for line tracking
void Default_Routine(void)/* BEGIN Default_Routine(); */
{
if(rc_dig_in06 == 0) /* if dark is seen */
{
pwm01=pwm03=127; /* turn left motors off */
pwm02=pwm04=96; /* turn right motors forward slowly */
}
else
{
pwm01=pwm03=159; /* turn left motors forward slowly */
pwm02=pwm04=127; /* turn right motors off */
}
printf("%d
", rc_dig_in06); /* print light sensor readings */
} /* END Default_Routine(); */
take the code from inside the Default_Routine() function, and put it in the User_Autonomous_Code() function (in user_routines_fast.c) instead. it should look like this:
/* in user_routines_fast.c */
void User_Autonomous_Code(void)
{
while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
if(rc_dig_in06 == 0) /* if dark is seen */
{
pwm01=pwm03=127; /* turn left motors off */
pwm02=pwm04=96; /* turn right motors forward slowly */
}
else
{
pwm01=pwm03=159; /* turn left motors forward slowly */
pwm02=pwm04=127; /* turn right motors off */
}
printf("%d
", rc_dig_in06); /* print light sensor readings */
Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
}
}
}