Home ยป Create your own Arduino mfs2020 Radio stack

Create your own Arduino mfs2020 Radio stack

by Bits and Droids
Published: Last Updated on 0 comment
Arduino flight sim components

We’ve made many variations of basic radios, but to be honest, most of the content I’ve created around this topic is quite dated. This guide will help you through all the basic steps needed to create your very first radio stack to control the Microsoft Flight Simulator 2020 radios. Don’t forget to download the latest version of the connector from the downloads page.

Components used

(some of these are affiliate links that help support the content)

  • Soldering Iron Hakko FX888D – https://amzn.to/335tljA
  • Arduino Uno – https://amzn.to/3xEPFP1
  • Dupont cables – https://amzn.to/2S8ajXt
  • Dual concentric rotary encoder – https://bit.ly/3nE98Ll
  • TM1637 6 digit encoders – https://bit.ly/3eDZowc

The full code used

#include <TM1637_6D.h>
#include<BitsAndDroidsFlightConnector.h>
#include<Encoder.h>


//connector
BitsAndDroidsFlightConnector connector(false);

//Rotary block
const byte innerA = 2;
const byte innerB = 4;

const byte outerA = 3;
const byte outerB = 5;

Encoder rotaryInner(innerA, innerB);
Encoder rotaryOuter(outerA, outerB);

long oldMhzPosition = -999;
long newMhzPosition;

long oldKhzPosition = -999;
long newKhzPosition;

//Screens
const byte dioActive = 8;
const byte clkActive = 11;

const byte dioStandby = 9;
const byte clkStandby = 10;

TM1637_6D segActiveFreq(clkActive,dioActive);
TM1637_6D segStandbyFreq(clkStandby, dioStandby);

//Button
const byte btn = 7;
const byte encoderBtn = 6;

//Variables to check against
String oldActiveCom ="123.456";
String oldStandbyCom="123.456";

String newActiveCom;
String newStandbyCom;


void setup() {
  
  Serial.begin(115200);
  Serial.setTimeout(15);

  pinMode(encoderBtn, INPUT_PULLUP);


  segActiveFreq.init();
  segActiveFreq.set(BRIGHT_TYPICAL);

  segStandbyFreq.init();
  segStandbyFreq.set(BRIGHT_TYPICAL);

  segActiveFreq.displayFloat(123.456);
  segStandbyFreq.displayFloat(123.456);

}

void loop() {
  connector.dataHandling();
  newActiveCom = connector.getActiveCom1();
  if(newActiveCom != oldActiveCom){
    segActiveFreq.displayFloat(newActiveCom.toFloat());
    oldActiveCom = newActiveCom;
  }

  newStandbyCom = connector.getStandbyCom1();
  if(newStandbyCom != oldStandbyCom){
    segStandbyFreq.displayFloat(newStandbyCom.toFloat());
    oldStandbyCom = newStandbyCom;
  }
  
  newMhzPosition = rotaryOuter.read();
  // This is an example if your encoder is too responsive
  if(newMhzPosition != oldMhzPosition){
    //if the step is bigger than 2 indents
    if(newMhzPosition - oldMhzPosition >= 2){
       Serial.println(connector.sendCom1WholeInc()); 
       oldMhzPosition = newMhzPosition;
    } else if(newMhzPosition - oldMhzPosition <= -2){
       Serial.println(connector.sendCom1WholeDec());
       oldMhzPosition = newMhzPosition;
    }
    
  }

  newKhzPosition = rotaryInner.read();
  if(newKhzPosition != oldKhzPosition){
    if(newKhzPosition > oldKhzPosition){
      Serial.println(connector.sendCom1FractInc());
  } else{
    Serial.println(connector.sendCom1FractDecr());
  }
  oldKhzPosition = newKhzPosition;
  }
  if(digitalRead(encoderBtn) == LOW){
    Serial.println(connector.sendSwapCom1());
    delay(200);
  }

}

Rotary encoders

For a full article on dual concentric rotary encoders, go check out this article. Because my component library doesn’t image a dual concentric rotary encoder, I broke it down. Under the hood, these encoders are just 2 regular rotary encoders plus a button.

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