void calibrateRight90() { int calibrated = 0; right90ticks = 73; printf("\ncalibrate right 90"); while(!start_button()) { sleep(.1); } while (!calibrated) { printf("\n%d ticks", right90ticks); while(!start_button()) { sleep(.1); } right90(0); sleep(.5); right90(0); printf("\nstart-keep stop-cont"); while (!start_button() && !stop_button()) { sleep(.1); } if (start_button()) calibrated = 1; right90ticks += 2; } printf("\nset at %d", right90ticks); while(!start_button()) { sleep(.1); } } void calibrateLeft90() { int calibrated = 0; left90ticks = 75; printf("\ncalibrate left 90"); while(!start_button()) { sleep(.1); } while (!calibrated) { printf("\n%d ticks", left90ticks); while(!start_button()) { sleep(.1); } left90(0); sleep(.5); left90(0); printf("\nstart-keep stop-cont"); while (!start_button() && !stop_button()) { sleep(.1); } if (start_button()) calibrated = 1; left90ticks += 2; } printf("\nset at %d", left90ticks); while(!start_button()) { sleep(.1); } } void calibrateRight180() { int calibrated = 0; right180ticks = 160; printf("\ncalibrate right 180"); while(!start_button()) { sleep(.1); } while (!calibrated) { printf("\n%d ticks", right180ticks); while(!start_button()) { sleep(.1); } right180(0); printf("\nstart-keep stop-cont"); while (!start_button() && !stop_button()) { sleep(.1); } if (start_button()) calibrated = 1; right180ticks += 3; } printf("\nset at %d", right180ticks); while(!start_button()) { sleep(.1); } } void calibrateLeft180() { int calibrated = 0; left180ticks = 160; printf("\ncalibrate left 180"); while(!start_button()) { sleep(.1); } while (!calibrated) { printf("\n%d ticks", left180ticks); while(!start_button()) { sleep(.1); } left180(0); printf("\nstart-keep stop-cont"); while (!start_button() && !stop_button()) { sleep(.1); } if (start_button()) calibrated = 1; left180ticks += 3; } printf("\nset at %d", left180ticks); while(!start_button()) { sleep(.1); } } void calibrateStraight() { int calibrated = 0; printf("\ncalibrate straight"); while(!start_button()) { sleep(.1); } while (!calibrated) { forwardUntilHitTimeout((long) 3000); printf("\nright? start-Y stop-N"); while (!start_button() && !stop_button()) { sleep(.1); } if (start_button()) { /*going to the right*/ straight += 20; } else { printf("\nleft? start-Y stop-N"); sleep(.5); while (!start_button() && !stop_button()) { sleep(.1); } if (start_button()) { /*going to the left*/ straight -= 20; } else { /*going straight*/ printf("\ngood? start-Y stop-N"); sleep(.5); while (!start_button() && !stop_button()) { sleep(.1); } if (start_button()) { break; } } } } printf("\nstraightened out!"); while(!start_button()) { sleep(.1); } }