while(1)
{
//delay_ms(45);
//Look for user input
check_for_button();
//Find tilt magnitude
//===================================================================
tilt_value = read_tilt();
tilt_angle = tilt_center - tilt_value;
//===================================================================
//Find gyro magnitude
//===================================================================
gyro_value = read_gyro();
gyro_amount = gyro_center - gyro_value;
//===================================================================
tilt_correction = tilt_angle * tilt_fudge;
gyro_correction = gyro_amount * gyro_fudge;
new_correction = tilt_correction + gyro_correction;
new_correction = new_correction * new_fudge;
//motor_correction = motor_correction + new_correction; //Integrate over time
motor_correction = new_correction; //
//if (abs(tilt_angle) <= 1) {putc('!'); motor_correction = 0;}
/*
printfloat("T=%f ", tilt_correction);
printfloat("G=%f ", gyro_correction);
printfloat("C=%f ", motor_correction);
*/
set_motors(motor_correction);
}