void correctForwardMotion() { //Get an initial value SensorPair left = getLeftSensorValues(); SensorPair right = getRightSensorValues(); left = calibratedValuesLeft(left); right = calibratedValuesRight(right); /** * Compare the two sets of values, and decide * whether an adjustment left or right is needed * * Now measured in cm meaning that larger value is, as per normal, further away */ if (sensorSide == 1) { if (left.FrontSensor < 100) { //if i can see a wall then follow it wallFollow(left); cmdDoPlay("<c"); } } else if (sensorSide == 2) { if (right.FrontSensor < 100) { wallFollow(right); cmdDoPlay("<d"); } } }
void CBOT_main(void) { STEPPER_open(); // Enables control of the steppers ATTINY_open(); // Enables reading of the buttons SPKR_open(SPKR_BEEP_MODE); //enables beeping LCD_open(); // Enables use of the LCD ADC_open();//open the ADC module while(1) { if(ATTINY_get_SW_state(ATTINY_SW3)) { smartGoToGoal(4,4); } if(ATTINY_get_SW_state(ATTINY_SW4)) { wander('a'); } if (ATTINY_get_SW_state(ATTINY_SW5)) { char wall = 'l'; while(wall=='l'){ wall = wallFollow('l',4,5,10); } } //TODO:: Please write your application code } }