Home ยป Create your own landing gear lever for mfs2020

Create your own landing gear lever for mfs2020

by Bits and Droids
Published: Last Updated on 0 comment 202 views

Used in this tutorial (Amazon affiliate links that help support the channel):

  • Springs: https://amzn.to/318h28k
  • Arduino Leonardo / pro micro https://amzn.to/3mx3HyS or https://amzn.to/2ZBDaaD
  • LEDs https://amzn.to/3pUgJsk
  • Limit switches https://amzn.to/3GAzBT1

Gear I use:

  • Hakko soldering iron: https://amzn.to/3bsCOWo

Full code

Here you’ll find the full code I’m using on my own device. It also contains the code I’m using for the master warning and caution lights.

#include <BitsAndDroidsFlight32.h>
BitsAndDroidsFlight32 connector = BitsAndDroidsFlight32();



int leds[6] = {3,2,4,A3,5,7};
int up = A2;
int down = A1;
byte warningBtn = 8;
byte cautionBtn = 9;

byte oldWarningBtn = 0;
byte oldCautionBtn = 0;

byte oldUp = HIGH;
byte oldDown = HIGH;

bool oldWarning = true;
bool oldCaution =  true;
void setup() {
  Serial.begin(115200);
  // put your setup code here, to run once:
  for(int i = 0; i < 6; i++){
    pinMode(leds[i], OUTPUT);
    digitalWrite(leds[i],HIGH);
  }
  pinMode(warningBtn, INPUT_PULLUP);
  pinMode(cautionBtn, INPUT_PULLUP);
  pinMode(up,INPUT_PULLUP);
  pinMode(down, INPUT_PULLUP);
}

void loop() {
  connector.dataHandling();
  byte frontGear = connector.getGearCenterPositionPct();
  byte leftGear = connector.getGearRightPositionPct();
  byte rightGear = connector.getGearCenterPositionPct();
  bool curWarning = connector.getMasterWarningOn();
  if(oldWarning != curWarning){
    digitalWrite(leds[4], curWarning);
    oldWarning = curWarning;
  }
   bool curCaution = connector.getMasterCautionOn();
   if(oldCaution != curCaution){
    digitalWrite(leds[5], curCaution);
    oldCaution = curCaution;
  }
  if(connector.getMasterCautionOn()){

  }
  if(frontGear > 98){
    digitalWrite(leds[0],HIGH);
  } else{
    digitalWrite(leds[0],LOW);
  }
    if(leftGear > 98){
    digitalWrite(leds[2],HIGH);
  } else{
    digitalWrite(leds[2],LOW);
  }
    if(rightGear > 98){
    digitalWrite(leds[1],HIGH);
  } else{
    digitalWrite(leds[1],LOW);
  }

  if(frontGear < 5){
     for(int i = 0; i < 3; i++){
    pinMode(leds[i], OUTPUT);
    digitalWrite(leds[i],LOW);
  }
  digitalWrite(leds[3],HIGH);
  } 
  if(frontGear > 5){
    digitalWrite(leds[3],LOW);
  }
  byte curUp = digitalRead(up);
   if(oldUp != curUp){
   if(curUp == HIGH){
    
 connector.send(sendGearUp);

     }
     oldUp = curUp;
     delay(50);
   }

  byte curDown = digitalRead(down);
   if(oldDown != curDown){
  if(curDown == HIGH){
   
 connector.send(sendGearDown);

    }
      oldDown = curDown;
      delay(50);
   }
   byte curCautionBtn = digitalRead(cautionBtn);
  if(curCautionBtn != oldCautionBtn){
    Serial.println(sendMasterCaution);
    delay(350);
    oldCautionBtn = curCautionBtn;
  }  

  byte curWarningBtn = digitalRead(warningBtn);
  if(curWarningBtn != oldWarningBtn){
    Serial.println(sendMasterWarning);
    delay(350);
    oldWarningBtn = curWarningBtn;
  }  
 

}

You may also like

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept