|
Explore TEAMS!
|
Student /
CODE Include the Command Module API
#include "create.h"
// 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);
while(1)
{
cr8_update(cr8);
if(cr8->cliff_frontright_range < 500)
{
cr8_drive_direct(40,-40);
cr8_delay(15);
cr8_set_leds(0,1,0,0);
}
else if(cr8->cliff_frontleft_range < 500)
{
cr8_drive_direct(-40,100);
cr8_delay(15);
cr8_set_leds(1,0,0,0);
}
else if(cr8->cliff_frontleft_range > 800 && cr8->cliff_frontright_range > 800)
{
cr8_drive_direct(40,40);
cr8_delay(15);
cr8_set_leds(1,1,0,0);
}
}
cr8_free(cr8);
return(0);
}
|