void interruptions_left(void) //for interruptions appearing on the left to the track { straight_fwd(); // Go forward Delay10KTCYx(130); check_sensors(); if (SeeLine.b.Left&&!SeeLine.b.CntLeft&&SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //10100 { while(SeeLine.b.Left&&!SeeLine.b.CntLeft&&SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 sees nothing { //spin right spin_right(); check_sensors(); } } else if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&SeeLine.b.Center&&!SeeLine.b.CntRight&&SeeLine.b.Right) //00101 { straight_fwd(); // Go forward Delay10KTCYx(130); check_sensors(); if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { spin_right(); check_sensors(); } } } * }
void final_ends(void) //stops robot when it comes to black platform { straight_fwd(); //go straight Delay10KTCYx(150); //0.1875s check_sensors(); //constantly keeps checking to see LED combinations while(SeeLine.b.Left&&SeeLine.b.CntLeft&&SeeLine.b.Center&&SeeLine.b.CntRight&&SeeLine.b.Right) //11111 //all LEDs ON { motors_brake_all(); //stops all motor check_sensors(); //constantly keeps checking to see LED combinations } }
void Check_Gaps(void) //checks gaps and makes a 180 degree turn after going about 8cm (needs to be exact.) { int sensor_check = 0; //variable sensor check for(sensor_check; sensor_check < 10; sensor_check++) //executes 20 times, looking for gaps in each count. { check_sensors(); //constantly keeps checking for LED combinations if ( (SeeLine.B ) == 0b00000u) //all LEDs OFF { straight_fwd(); //go straight Delay10KTCYx(20); //0.025s OR 25ms. if( sensor_check == 9) //last condition { turn_180 (); straight_fwd(); } } else { sensor_check = 9; } } }
// main acts as a cyclical task sequencer void main(void) { OpenTimer0(TIMER_INT_OFF & T0_SOURCE_INT & T0_16BIT & T0_PS_1_64); initialization(); // function from sumovore.c // it sets up pwm (using timer2), // IO pins, the ADC, the // USART and the default // threshold printf("\n\rKwantlen APSC1299 simple curve follower -- with error codes\n\r"); ClrWdt(); // defined in <p18f4525.h> threshold = 650u; // to change from default value // uncomment and change to any unsigned int <1024u -- most usually <512u while(1) { check_sensors(); // from sumovore.c set_leds(); // function from sumovore.c switch(SeeLine.B) // this is a switch based on the sensor values, SeeLine.B allows us to input sensor states as a 5 bit binary value // it is already built into sumovore.c , so 0b11111 is all the sensors are on and 0b00000 is all sensors off { case 0b00100: motor_control(); break; case 0b01110: motor_control(); break; case 0: Robot_track_end(); break; } motor_control(); // function from motor_control.c ClrWdt(); // defined in <p18f4525.h> if(SeeLine.B==0) { } if(lvd_flag_set()) LVtrap(); } }
static gboolean applyConfig(gpointer p) { thermal *th = lxpanel_plugin_get_data(p); int critical; ENTER; if (th->str_cl_normal) gdk_color_parse(th->str_cl_normal, &th->cl_normal); if (th->str_cl_warning1) gdk_color_parse(th->str_cl_warning1, &th->cl_warning1); if (th->str_cl_warning2) gdk_color_parse(th->str_cl_warning2, &th->cl_warning2); remove_all_sensors(th); if(th->sensor == NULL) th->auto_sensor = TRUE; if(th->auto_sensor) check_sensors(th); else if (strncmp(th->sensor, "/sys/", 5) != 0) add_sensor(th, th->sensor, th->sensor, proc_get_temperature, proc_get_critical); else if (strncmp(th->sensor, "/sys/class/hwmon/", 17) != 0) add_sensor(th, th->sensor, th->sensor, sysfs_get_temperature, sysfs_get_critical); else add_sensor(th, th->sensor, th->sensor, hwmon_get_temperature, hwmon_get_critical); critical = get_critical(th); if(th->not_custom_levels){ th->warning1 = critical - 10; th->warning2 = critical - 5; } config_group_set_string(th->settings, "NormalColor", th->str_cl_normal); config_group_set_string(th->settings, "Warning1Color", th->str_cl_warning1); config_group_set_string(th->settings, "Warning2Color", th->str_cl_warning2); config_group_set_int(th->settings, "AutomaticLevels", th->not_custom_levels); /* TODO: clean obsolete setting config_setting_remove(th->settings, "CustomLevels"); */ config_group_set_int(th->settings, "Warning1Temp", th->warning1); config_group_set_int(th->settings, "Warning2Temp", th->warning2); config_group_set_int(th->settings, "AutomaticSensor", th->auto_sensor); config_group_set_string(th->settings, "Sensor", th->sensor); RET(FALSE); }
void process_AI(void) { printf("processing AI ... %i \n", temeraire_state.state); switch(temeraire_state.state) { case NOTHING : printf("State doing nothing \n"); break; case CHECKING_ENV : switch(check_sensors()) { case 0 : // Nothing printf("Rien a faire \n"); break; case 1 : speed_saveZ = TravelLengthZ; TravelLengthZ = 0; look_around(); temeraire_state.state = AVOIDING_WALL_FRONT; printf("Go to avoiding wall front \n"); system("espeak -a 200 \"Wall detected in front\" &"); //find_where_to_turn(1); //gettimeofday( &timebeforenextcheck, NULL ); break; case 2 : // front item > go left speed_saveZ = TravelLengthZ; TravelLengthX = - TravelLengthZ; temeraire_state.state = AVOIDING_ITEM_LEFT; printf("Goto Avoiding item left \n"); system("espeak -a 200 \"Object detected in front! Avoiding it by the left\" &"); break; case 3 : speed_saveZ = TravelLengthZ; TravelLengthX = TravelLengthZ; temeraire_state.state = AVOIDING_ITEM_RIGHT; printf("Goto Avoiding item right \n"); system("espeak -a 200 \"Object detected in front! Avoiding it by the right\" &"); break; case 4 : speed_saveZ = TravelLengthZ; TravelLengthX = TravelLengthZ; TravelRotationY = 5; temeraire_state.state = AVOIDING_WALL_SIDE; printf("Goto avoiding wall side \n"); system("espeak -a 200 \"Wall detected on my left\" &"); break; case 5 : speed_saveZ = TravelLengthZ; TravelLengthX = - TravelLengthZ; TravelRotationY = -5; temeraire_state.state = AVOIDING_WALL_SIDE; printf("Goto avoiding wall side \n"); system("espeak -a 200 \"Wall detected on my right\" &"); break; default : printf("Default State ?? \n"); break; } break; case AVOIDING_ITEM_LEFT : switch(check_sensors()) { case 0 : // Nothing printf("Stop avoiding item left \n"); system("espeak -a 200 \"Object avoided successfully\" &"); temeraire_state.state = CHECKING_ENV; TravelRotationY = 0; TravelLengthX = 0; TravelLengthZ = speed_saveZ; break; case 1 : TravelLengthZ = 0; look_around(); temeraire_state.state = AVOIDING_WALL_FRONT; printf("Goto avoiding wall front \n"); //find_where_to_turn(1); //gettimeofday( &timebeforenextcheck, NULL ); break; case 2 : // front item > go left TravelLengthZ = speed_saveZ; if((us_sensor_distance_front < US_FRONT_LIMIT)) TravelLengthZ = 0; else TravelLengthX += 3; break; case 3 : break; case 4 : TravelLengthZ = speed_saveZ; if((us_sensor_distance_right < US_SIDE_LIMIT)) TravelLengthZ = 0; else TravelLengthX += 2; break; case 5 : break; default : break; } break; case AVOIDING_WALL_FRONT : switch(check_sensors()) { case 0 : // Nothing printf("Stop avoiding wall front \n"); system("espeak -a 200 \"Wall avoided successfully\" &"); temeraire_state.state = CHECKING_ENV; TravelRotationY = 0; TravelLengthX = 0; TravelLengthZ = speed_saveZ; break; case 1 : TravelLengthZ = 10; // Go back //look_around(); //find_where_to_turn(1); //gettimeofday( &timebeforenextcheck, NULL ); break; case 2 : // front item > go left TravelRotationY = 10; break; case 3 : TravelRotationY = -10; break; case 4 : TravelRotationY = 10; break; case 5 : TravelRotationY = -10; break; default : break; } break; case AVOIDING_ITEM_RIGHT : switch(check_sensors()) { case 0 : // Nothing printf("Stop avoiding item right \n"); system("espeak -a 200 \"Object avoided successfully\" &"); temeraire_state.state = CHECKING_ENV; TravelRotationY = 0; TravelLengthX = 0; TravelLengthZ = speed_saveZ; break; case 1 : TravelLengthZ = 0; look_around(); temeraire_state.state = AVOIDING_WALL_FRONT; printf("Goto avoiding wall front \n"); //find_where_to_turn(1); //gettimeofday( &timebeforenextcheck, NULL ); break; case 2 : // front item > go left break; case 3 : TravelLengthZ = speed_saveZ; if((us_sensor_distance_front < US_FRONT_LIMIT)) TravelLengthZ = 0; else TravelLengthX -= 3; break; case 4 : break; case 5 : TravelLengthZ = speed_saveZ; if((us_sensor_distance_left < US_SIDE_LIMIT)) TravelLengthZ = 0; else TravelLengthX -= 2; break; default : break; } break; case AVOIDING_WALL_SIDE : switch(check_sensors()) { case 0 : // Nothing printf("Stop avoiding wall \n"); system("espeak -a 200 \"Wall avoided successfully\" &"); temeraire_state.state = CHECKING_ENV; TravelRotationY = 0; TravelLengthX = 0; TravelLengthZ = speed_saveZ; break; case 1 : TravelLengthZ = 0; look_around(); temeraire_state.state = AVOIDING_WALL_FRONT; printf("Goto avoiding wall front \n"); break; case 2 : // front item > go left TravelLengthZ = speed_saveZ; if((us_sensor_distance_front < US_FRONT_LIMIT)) TravelLengthZ = 0; else TravelLengthX = - speed_saveZ; break; temeraire_state.state = AVOIDING_ITEM_LEFT; case 3 : TravelLengthZ = speed_saveZ; if((us_sensor_distance_front < US_FRONT_LIMIT)) TravelLengthZ = 0; else TravelLengthX = speed_saveZ; break; temeraire_state.state = AVOIDING_ITEM_RIGHT; break; case 4 : break; case 5 : break; default : break; } break; default : printf("Default state AI \n"); break; } }
void sharp_left_turns(void) //sharp left turns { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_left(); //spins left (was spin right in v004) check_sensors(); //constantly keeps checking to see LED combinations } } else if (SeeLine.b.Left&&!SeeLine.b.CntLeft&&SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//10100 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_left(); //spins left (was spin right in v004); check_sensors(); //constantly keeps checking to see LED combinations } } } //WE ADDED THIS LINE TO SEE IF IT MAKES A DIFFERENCE (ADDED IN v008) else if (SeeLine.b.Left&&SeeLine.b.CntLeft&&SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//11100 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_left(); //spins left (was spin right in v004) check_sensors(); //constantly keeps checking to see LED combinations } } } //THIS LINE FUNCTION ENDS HERE else if (SeeLine.b.Left&&SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//11000 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_left(); //spins left (was spin right in v004); check_sensors(); //constantly keeps checking to see LED combinations } } } else if (!SeeLine.b.Left&&SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//01000 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_left(); //spins left (was spin right in v004) check_sensors(); //constantly keeps checking to see LED combinations } } } else if (!SeeLine.b.Left&&SeeLine.b.CntLeft&&SeeLine.b.Center&&SeeLine.b.CntRight&&!SeeLine.b.Right)//01110 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_left(); //spins left (was spin right in v004) check_sensors(); //constantly keeps checking to see LED combinations } } } else if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00100 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_left(); //spins left (was spin right in v004) check_sensors(); //constantly keeps checking to see LED combinations } } } else if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&SeeLine.b.Center&&SeeLine.b.CntRight&&!SeeLine.b.Right)//00110 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_left(); //spins left (was spin right in v004) check_sensors(); //constantly keeps checking to see LED combinations } } } else if (!SeeLine.b.Left&&SeeLine.b.CntLeft&&SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//01100 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//0000 { spin_left(); //spins left (was spin right in v004) check_sensors(); //constantly keeps checking to see LED combinations. } } } else; }
void sharp_right_turns(void) //sharp right turns { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 sees nothing { spin_right(); //spins right check_sensors(); //constantly keeps checking to see LED combinations } } else if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&SeeLine.b.Center&&!SeeLine.b.CntRight&&SeeLine.b.Right) //00101 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations. if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { spin_right(); //spins right check_sensors(); //constantly keeps checking to see LED combinations. } } } //THIS WAS ADDED IN v008 else if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&SeeLine.b.Center&&SeeLine.b.CntRight&&SeeLine.b.Right)//00111 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_right(); //spins right check_sensors(); //constantly keeps checking to see LED combinations } } } //FUNCTION STOPS HERE else if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&SeeLine.b.CntRight&&SeeLine.b.Right) //00011 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { spin_right(); //spins right check_sensors(); //constantly keeps checking to see LED combinations } } } else if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&SeeLine.b.CntRight&&!SeeLine.b.Right)//00010 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_right(); //spins right check_sensors(); //constantly keeps checking to see LED combinations. } } } else if (!SeeLine.b.Left&&SeeLine.b.CntLeft&&SeeLine.b.Center&&SeeLine.b.CntRight&&!SeeLine.b.Right)//01110 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations. if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_right(); //spins right check_sensors(); //constantly keeps checking to see LED combinations } } } else if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00100 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_right(); //spins right check_sensors(); //constantly keeps checking to see LED combinations } } } else if (!SeeLine.b.Left&&SeeLine.b.CntLeft&&SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//01100 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_right(); //spins right check_sensors(); //constanlty keeps checking to see LED combinations } } } else if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&SeeLine.b.Center&&SeeLine.b.CntRight&&!SeeLine.b.Right)//00110 { straight_fwd(); //go straight Delay10KTCYx(130); //Changed from Delay10KTCYx(50); (v 009) check_sensors(); //constantly keeps checking to see LED combinations. if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_right(); //spins right check_sensors(); //constantly keeps checking to see LED combinations. } } } else; }
void left_right_angle_turns(void) //left right angle turns, if else cases cover sharp turns aswell { straight_fwd(); //go straight Delay10KTCYx(50); //Changed from Delay10KTCYx(25); (v 009) check_sensors(); //constantly keeps checking to see LED combinations. if ( (SeeLine.B ) == 0b00000u) //all LEDS OFF { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_left(); //spins left (was spin right in v004) check_sensors(); //constantly keeps checking to see LED combinations. } } else if (!SeeLine.b.Left&&SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//01000 { straight_fwd(); Delay10KTCYx(50); //Changed from Delay10KTCYx(25); (v 009) check_sensors(); if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_left(); //spins left (was spin right in v004). check_sensors(); //constantly keeps checking to see LED combinations. } } } else if (!SeeLine.b.Left&&SeeLine.b.CntLeft&&SeeLine.b.Center&&SeeLine.b.CntRight&&!SeeLine.b.Right)//01110 { straight_fwd(); //go straight Delay10KTCYx(50); //Changed from Delay10KTCYx(25); (v 009) check_sensors(); //constantly keeps checking to see LED combinations. if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_left(); //spins left (was spin right in v004). check_sensors(); //constantly keeps checking to see LED combinations. } } } else if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00100 { straight_fwd(); //go straight Delay10KTCYx(50); //Changed from Delay10KTCYx(25); (v 009) check_sensors(); //constantly keeps checking to see LED combinations. if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_left(); //spins left (was spin right in v004). check_sensors(); //constantly keeps checking to see LED combinations. } } } else if (!SeeLine.b.Left&&SeeLine.b.CntLeft&&SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//01100 { straight_fwd(); //go straight Delay10KTCYx(50); //Changed from Delay10KTCYx(25); (v 009) check_sensors(); //constantly keeps checking to see LED combinations. if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right)//00000 { spin_left(); //spins left (was spins right in v004); check_sensors(); //constantly keeps checking to see LED combinations. } } } else; } }
void right_right_angle_turns(void) //right right angle turns, if-else cases cover sharp turns as well { straight_fwd(); Delay10KTCYx(50); //Changed from Delay10KTCYx(25); (v 009) check_sensors(); //constantly keeps checking to see LED combinations. if ( (SeeLine.B ) == 0b00000u) //all LEDs OFF. { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //while all off; 00000 { spin_right(); //spins the robot right. check_sensors(); //constantly keeps checking to see LED combinations. } } else if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&SeeLine.b.CntRight&&!SeeLine.b.Right) //00010 { straight_fwd(); //go straight Delay10KTCYx(50); //Changed from Delay10KTCYx(25); (v 009) check_sensors(); if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { spin_right(); //spins the robot right. check_sensors(); //constantly keeps checking to see LED combinations. } } } else if (!SeeLine.b.Left&&SeeLine.b.CntLeft&&SeeLine.b.Center&&SeeLine.b.CntRight&&!SeeLine.b.Right) //01110 { straight_fwd(); //Go straight. Delay10KTCYx(50); //Changed from Delay10KTCYx(25); (v 009) check_sensors(); //constantly keeps checking to see LED combinations. if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { spin_right(); //Rotates Right check_sensors(); //constantly keeps checking to see LED combinations. } } } else if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00100 { straight_fwd(); //Go straight. Delay10KTCYx(50); //Changed from Delay10KTCYx(25); (v 009) check_sensors(); //contantly keeps checking to see LED combinations. if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { spin_right(); //spins right check_sensors(); //constantly keeps checking to see LED combinations. } } } else if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&SeeLine.b.Center&&SeeLine.b.CntRight&&!SeeLine.b.Right) //00110 { straight_fwd(); //Go straight. Delay10KTCYx(50); //Changed from Delay10KTCYx(25); (v 009) check_sensors(); //constantly keeps checking to see LED combinations. if (!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { while(!SeeLine.b.Left&&!SeeLine.b.CntLeft&&!SeeLine.b.Center&&!SeeLine.b.CntRight&&!SeeLine.b.Right) //00000 { spin_right(); //Rotates right. check_sensors(); //constantly keeps checking to see LED combinations. } } } else; }