
482 Chapter 24 • Simulating Flight
The important thing to remember is that the arm of the lever at the top is
double the length of that at the bottom, meaning that in respect to the bank
sensor, you need double the ticks from the rotation to cover the same angle.This
leads to the formula:
pitch=(SENSOR_PITCH*15)/32;
We chose for the throttle a scale of ten values from 0 to 9.To make the rotary
control a bit less sensitive, we counted an increment in throttle every four ticks of
the sensors, and added some code to ensure its value stays in the right range.
temp_thr=throttle+(SENSOR_THROTTLE-old_sensor_throttle)/4;
old_sensor_throttle=SENSOR_THROTTLE;