Results 1 to 2 of 2
  1. #1
    New Member
    Join Date
    Mar 2010
    Location
    Netherlands
    Posts
    3
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Air Speed Indicator

    Hello,

    At this very moment I'm converting single needle gauges from Simkits to work with the Arduino Mega.

    I've managed to get the vertical speed indicator working ( Thanks to Jim's code ) but the Airspeed indicator not.

    I'm using the sketch below witch is for the vertical speed original, but made same changes.
    Can somebody tell me what I'm doing wrong ??

    Thank you very much
    PH-AVI

    // Drive a servo, based on "P" (Indicated Airspeed) out of link2fs
    // Needs to be compiled in Arduino version 0022 or 0023
    // servo "signal" (yellow) onto pin 8
    // Red servo wire to +5V (on Arduino)
    // Brown servo wire to GND on Arduino.
    // Dont use large servo's (too much currant draw)
    // No damping has been applied to the reading
    // Tested with a "Hitec HS80" apollo-80 servo

    #include //Add's the servo library
    Servo myservo; // Names the servo
    int j1; // Variable used by serial.read
    String airsp, airspold; // variables used for Air speed
    void setup() // the set up loop
    {
    myservo.attach(; // attaches the servo to pin 8
    Serial.begin(115200); // sets up the serial port
    }

    void loop() // the main loop where it all happens
    {
    if (Serial.available() > 0) { // read the oldest byte in the serial buffer:
    j1 = Serial.read(); // Read a serial byte
    if (j1 == 'P'){ // Found the reading "Indicated airspeed"
    delay (11); // It seems to need a delay here
    airsp = char(Serial.read()); // first digit of the data
    airsp += char(Serial.read()); // Second digit and so-on
    airsp += char(Serial.read());
    airsp += char(Serial.read());
    airsp += char(Serial.read());
    airsp += char(Serial.read());
    if (airsp != airspold){ // checks to see if its different to the "old" reading
    char carray[6]; //converting a string to number sequence
    airsp.toCharArray(carray, sizeof(carray)); //converting string to number sequence
    int n = atoi(carray); //converting string to number sequence
    n= n * 10; //Makes the reading more "sensitive"
    n = map(n, 200, 0, 0, 179); //Maps the readings to the servo
    myservo.write(n); //Sends the data to servo
    delay (11); // Probably not neccesary
    airspold = airsp; // Writes the current reading to the "old" string.
    } // end of it's a different reading section
    } // end of "found P" section
    } // end of "if serial available" section
    } // end of void loop ,,, it starts all over again

  2. #2
    150+ Forum Groupie BuzziBi's Avatar
    Join Date
    Mar 2013
    Location
    Norway
    Posts
    275
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Air Speed Indicator

    if (j1 == 'P'){ // Found the reading "Indicated airspeed"
    This line is from the old Link2fs keys or Link2fs in/out, and will not work with the Link2fs Multi!
    Use the Demo INOs that comes with the Link2fs Multi for FSX.
    There you will see that this version uses:
    int CodeIn;// used on all serial reads
    and not
    int j1; // Variable used by serial.read

    Good luck
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------