|
Explore TEAMS!
|
Student /
RuggCombo/* Add comment - Allison Rugg - Blue Cohort - Combo HW - 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: int v; // Initialize GLOBAL Variables used in program: int v = 20; // 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_byte_tx(140); cr8_byte_tx(1); cr8_byte_tx(7); cr8_byte_tx(91); cr8_byte_tx(4); cr8_byte_tx(91); cr8_byte_tx(8); cr8_byte_tx(91); cr8_byte_tx(8); cr8_byte_tx(88); cr8_byte_tx(4); cr8_byte_tx(91); cr8_byte_tx(8); cr8_byte_tx(96); cr8_byte_tx(12); cr8_byte_tx(84); cr8_byte_tx(8); cr8_update(cr8); while(cr8->button_play==0) {
cr8_set_leds(1,0,150,255);
cr8_delay(250);
cr8_update(cr8);
cr8_set_leds(1,0,150,255);
cr8_delay(250);
cr8_update(cr8);
}
if(cr8->button_play==1) {
while(cr8->cliff_right==0 && cr8->cliff_left==0 && cr8->cliff_frontright==0 && cr8->cliff_frontleft==0 && cr8->wheeldrop_right==0 && cr8->wheeldrop_left==0 && cr8->wheeldrop_caster==0)
{
cr8_drive(v,1999);
cr8_set_leds(1,1,50,150);
while(v<=500 && cr8->cliff_right==0 && cr8->cliff_left==0 && cr8->cliff_frontright==0 && cr8->cliff_frontleft==0 && cr8->wheeldrop_right==0 && cr8->wheeldrop_left==0 && cr8->wheeldrop_caster==0)
{
cr8_drive(v, 1999);
cr8_update(cr8);
if(cr8->button_play)
{
for(v = v; v<=200; v++);
{
cr8_drive(v,1999);
cr8_update(cr8);
}
}
else if(cr8->button_advance)
{
for(v = v; v>=-200; v--);
{
cr8_drive(v,1999);
cr8_update(cr8);
}
}
else if(cr8->bumper_right==1 && cr8->bumper_left==0)
{
cr8_set_leds(0,1,250,255);
cr8_set_mc_led1(1);
cr8_update(cr8);
}
else if(cr8->bumper_left==1 && cr8->bumper_right==0)
{
cr8_set_mc_led0(1);
cr8_byte_tx(141);
cr8_byte_tx(1);
cr8_update(cr8);
}
else if(cr8->bumper_left==1 && cr8->bumper_right==1)
{
cr8_set_mc_led0(1);
cr8_set_mc_led1(1);
cr8_update(cr8);
}
}
}
while(cr8->cliff_right || cr8->cliff_left || cr8->cliff_frontright || cr8->cliff_frontleft || cr8->wheeldrop_right || cr8->wheeldrop_left || cr8->wheeldrop_caster)
cr8_beep_error( );
{
cr8_set_leds(0,1,255,255);
cr8_delay(250);
cr8_set_leds(0,1,255,255);
cr8_delay(250);
cr8_update(cr8);
}
}
} // 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
|