Projects / Control surface angle gauge

Control surface angle gauge

Beginner2 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. NANO

    Wire the sensor and display

    Both on A4 and A5 with 5V and GND.

  2. NANO

    Wire the button

    D2 to GND.

  3. NANO17.6 mASSD1306

    Install the libraries

    Adafruit SSD1306 and Adafruit GFX.

  4. NANO

    Upload the sketch

    An angle appears on the display.

  5. NANO

    Hold the surface level

    Press the button to zero it.

  6. NANOMPU6050tilt 35°

    Move to full up and full down

    Read the maximums.

  7. NANO

    Repeat on the other surface

    Compare the throws.

  8. NANOMPU6050tilt 35°

    Clear the maximums

    Hold the button for one second.

In short

How do you build a control surface angle gauge?

A small motion sensor taped to an elevator or aileron shows its deflection in degrees, so you can set the same control throws on both sides of a model plane. You need Arduino Nano, MPU6050 IMU, SSD1306 OLED Display, Tactile push button 6 mm, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points. It takes 8 steps and about 120 minutes.

Level
Beginner
Time
About 120 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
MPU6050 VCCNano 5VPower (most boards have a regulator, check yours)
MPU6050 GNDNano GNDCommon ground
MPU6050 SDA and OLED SDANano A4Shared I2C data
MPU6050 SCL and OLED SCLNano A5Shared I2C clock
OLED VCC and GNDNano 5V and GNDPower (check your OLED accepts 5 V)
Zero buttonNano D2 and GNDShort press zeroes, long press clears the maximums

Code

An accelerometer measures gravity, so when it is still it can tell how it is tilted. A MPU6050 stuck to a flap or elevator reads the direction of gravity along its axes, and the angle about the hinge is the arctangent of two of them. The sketch reads the six accelerometer bytes directly from the chip, converts them to an angle, and smooths the result with a simple filter so small vibrations do not make the number jump. A press of the button sets the present position as zero, which you do with the surface held level. The display then shows the deflection in degrees, positive one way and negative the other, along with the largest values reached, so you can move the surface to each end and read the throw. Compare the up and down numbers on the two ailerons to set them equally. Mount the sensor with its X axis along the hinge line, and keep it flat on the surface. This method works only when the model is still, because acceleration from movement adds to gravity. Remove the propeller and disconnect the flight battery before you measure, so the motor cannot start.

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 oled(128, 64, &Wire, -1);

const uint8_t MPU = 0x68;
const int BTN = 2;

float smooth = 0, zeroOffset = 0, maxUp = 0, maxDown = 0;
bool wasPressed = false, longHandled = false;
unsigned long pressedAt = 0, lastDraw = 0;

bool readAngle(float &deg) {
  Wire.beginTransmission(MPU);
  Wire.write(0x3B);                                    // first accelerometer register
  if (Wire.endTransmission(false) != 0) return false;
  Wire.requestFrom(MPU, (uint8_t)6, (uint8_t)true);
  if (Wire.available() < 6) return false;
  int16_t x = (Wire.read() << 8) | Wire.read();
  int16_t y = (Wire.read() << 8) | Wire.read();
  int16_t z = (Wire.read() << 8) | Wire.read();
  (void)x;                                             // the hinge line runs along the sensor X axis
  deg = atan2((float)y, (float)z) * 180.0 / PI;        // roll angle about the X axis
  return true;
}

void setup() {
  pinMode(BTN, INPUT_PULLUP);
  Wire.begin();
  Wire.beginTransmission(MPU);
  Wire.write(0x6B); Wire.write(0);                     // wake the sensor
  Wire.endTransmission(true);
  if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { while (true) {} }
  float a;
  if (readAngle(a)) smooth = a;
}

void loop() {
  float a;
  if (readAngle(a)) smooth = 0.85 * smooth + 0.15 * a;   // low-pass filter to calm the reading
  float angle = smooth - zeroOffset;
  if (angle > maxUp) maxUp = angle;
  if (angle < maxDown) maxDown = angle;

  bool pressed = (digitalRead(BTN) == LOW);
  if (pressed && !wasPressed) { pressedAt = millis(); longHandled = false; }
  if (pressed && !longHandled && millis() - pressedAt >= 1000) {   // long press: clear maximums
    maxUp = 0; maxDown = 0; longHandled = true;
  }
  if (!pressed && wasPressed && !longHandled && millis() - pressedAt > 40) {
    zeroOffset = smooth;                                // short press: surface is level, set zero
    maxUp = 0; maxDown = 0;
  }
  wasPressed = pressed;

  if (millis() - lastDraw >= 100) {
    lastDraw = millis();
    oled.clearDisplay();
    oled.setTextColor(SSD1306_WHITE);
    oled.setTextSize(1);
    oled.setCursor(0, 0); oled.print("Control surface angle");
    oled.setTextSize(3);
    oled.setCursor(0, 14); oled.print(angle, 1);
    oled.setTextSize(1);
    oled.setCursor(0, 46); oled.print("Max up   "); oled.print(maxUp, 1);
    oled.setCursor(0, 56); oled.print("Max down "); oled.print(maxDown, 1);
    oled.display();
  }
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Sensor flat and stillAngle near zero after zeroing
Tilt one way by 10 degreesAbout +10
Tilt the other wayAbout -10
Move to the limitsMax up and Max down values are held
Long pressMaximums reset to zero

If it does not work

Angle jumps around

Hold the model still, the sensor reads motion as well as gravity.

Reads zero or nonsense

Check A4 and A5 and the MPU6050 address at 0x68.

Angle is wrong by a large amount

Mount the sensor with its X axis along the hinge.

Blank screen

Check the OLED address.

Max values never clear

Hold the button for a full second.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the control surface angle gauge?

Arduino Nano, MPU6050 IMU, SSD1306 OLED Display, Tactile push button 6 mm, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points.

How long does the control surface angle gauge take to build?

About 120 minutes for a beginner maker, in 8 steps.

How do I know the control surface angle gauge works?

Sensor flat and still: Angle near zero after zeroing. Tilt one way by 10 degrees: About +10. Tilt the other way: About -10.

Angle jumps around: what should I check?

Hold the model still, the sensor reads motion as well as gravity.

Reads zero or nonsense: what should I check?

Check A4 and A5 and the MPU6050 address at 0x68.

Angle is wrong by a large amount: what should I check?

Mount the sensor with its X axis along the hinge.

Blank screen: what should I check?

Check the OLED address.