|
Explore TEAMS!
|
Student /
RuggLineFollow/* Add comment - name - cohort - assignment - date - and overview here
// Include the Command Module API
// Pointer to the Sensor Data structure cr8_t *cr8; // Declare any new function prototypes here: // For example: int dashboard(int counter, char partnumber); // Declare GLOBAL constants used in program: // Declare GLOBAL Variables used in program: // Initialize GLOBAL Variables used in program: // Declaraion for function "main" int main(void) { // Allocate memory for sensor data structure
cr8 = cr8_alloc();
/* Initialize the Create and Command Module
Sync communications settings. */
cr8_init(cr8);
// Declare LOCAL constants used in function main:
// For example: const int Pi100 = 314;
// Declare LOCAL Variables used in function main:
// For example: int i, j;
int black; // Initialize LOCAL Variables used in function main: black = 800; // For example: i = 1; /* write code for main here! */ cr8_stopwatch_start( ); cr8_update(cr8); while(cr8_stopwatch_time( )<=1200); {
while(cr8->button_play==0 && cr8_stopwatch_time( )<1200 && safe)
{
switch(cr8_stopwatch_time( ) %2)
{
case 0:
{
cr8_set_leds(1,0,100,255);
cr8_drive_direct(0,0);
cr8_update(cr8);
}
case 1:
{
cr8_set_leds(0,0,100,255);
cr8_drive_direct(0,0);
cr8_update(cr8);
}
}
}
while(safe)
{
cr8_set_leds(1,1,100,255);
cr8_drive_direct(200,200);
while((cr8->cliff_frontright_range<=black || cr8->cliff_right_range<=black) && safe && cr8_stopwatch_time( )<=1200)
{
cr8_set_leds(0,1,0,255);
cr8_drive_direct(200,100);
cr8_update(cr8);
cr8_stopwatch_time( );
}
while((cr8->cliff_frontleft_range<=black || cr8->cliff_left_range<=black) && safe && cr8_stopwatch_time( )<1200)
{
cr8_set_leds(1,0,0,255);
cr8_drive_direct(100,200);
cr8_update(cr8);
cr8_stopwatch_time( );
}
while(cr8->cliff_frontleft_range>black && cr8->cliff_frontright_range>black && cr8->cliff_left_range>black && cr8->cliff_right_range>black && safe && cr8_stopwatch_time( )<1200)
{
cr8_drive_direct(200,200);
cr8_update(cr8);
cr8_stopwatch_time( );
}
}
while(!safe && cr8_stopwatch_time( )<1200)
{
cr8_set_leds(1,1,255,255);
cr8_drive_direct(0,0);
cr8_beep_short( );
cr8_update(cr8);
cr8_stopwatch_time( );
}
}
cr8_free(cr8);
return(0);
} // End of function main /* Declare other functions you create here... For example, to define function xxxxx of type integer (int) with two input parameters, sample_num and code... int xxxxx(int sample_num, char code) { // Declare LOCAL constants used in function xxxxx: // Declare LOCAL Variables used in function xxxxx: // Initialize LOCAL Variables ised in function xxxxx: // Write code for function XXXXX here: //Return int value for function xxxxx: return(1); You must always return a value to sending program --in this case a 1 to indicate fn done with no problems. } // End of function xxxxx
|