Results 1 to 6 of 6
  1. #1
    75+ Posting Member
    Join Date
    Feb 2010
    Location
    London
    Posts
    87
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Barometric presure

    Hi thee
    At the moment I'm working on Barometric presure in Airbus.
    Link2FS only has Koh/snam reading,but it does not have hPa.
    So was thinking of coverting one to another.

    So basicaly 1inHg=33.638hPa
    but I'm not sure how to programe.I have 2 buttons that switching betwen 2 values,but how to programe it that I do not know.

    I was trying somthing like
    lcd.print(QNH)*33.638;
    but that does not work

    hee is my ino fie it is modification of Jim COM NAV the decription is a but hectic.

    /*

    This sketch is a complete radio head for FSX
    It needs to be used with Link2fs_Multi
    It was compiled with Arduino version 1.1

    Full project info at http://www.jimspage.co.nz/intro.htm
    This example code is in the public domain.
    July 2013
    Once you get it going you may be able to remove some DELAY's
    */



    #include "math.h"
    #include "Quadrature.h"
    #include
    Quadrature quad1(8, 9); // freqency
    Quadrature quad2(52, 53); // QNH
    LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
    int buttonold;
    int CodeIn;// used on all serial reads
    int X;// a rotary variable
    int Xold;// the old reading
    int Xdif;// the difference since last loop
    int R;// a variable
    int Rold;// the old reading
    int Rdif;// the difference since last loop
    int active; // the mode thats active
    int activeold;
    int mark; // shows where the cursor is in the likes of ADF etc
    int pulseOn = 0;// the loop that pulses the LED's
    unsigned long TimeStart = 0; //used in pulsing LED's
    unsigned long TimeNow = 0;
    unsigned long TimeInterval = 500;

    String spd, spdold, alt, altold, QNH, QNHold, aphdg, aphdgold, apalt, apaltold, apvs, apvsold, apspeed, apspeedold, oldpinStateSTR, pinStateSTR, pinStateString, APsp, APspold, stringnewstate,stringoldstate, com1, com1old, com1sb, com1sbold,com2, com2old, com2sb,com2sbold, airsp, airspold, altit, altitold;
    String nav1, nav1old, nav1sb, nav1sbold, nav2, nav2old, nav2sb, nav2sbold;
    String adf, adfold, xpdr, xpdrold, dme1, dme1old, dme2, dme2old, pitot, pitotold;
    String AnunB = "0", AnunC = "0", AnunD = "0", AnunE = "0", AnunH = "0";
    String AnunBx = "0", AnunCx = "0", AnunDx = "0", AnunEx = "0", AnunHx = "0";
    String gearM;
    String gearR;
    String gearL;


    char blank = 255;

    void setup()
    {
    lcd.begin(20, 4); // set up the LCD's number of columns and rows:
    stringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
    for (int doutPin = 10; doutPin <= 37; doutPin++) // setup the input pins
    {
    pinMode(doutPin, INPUT);
    digitalWrite(doutPin, HIGH);
    }
    for (int PinNo = 54; PinNo <= 69; PinNo++)// Get all the OUTPUT pins ready.
    {
    pinMode(PinNo, OUTPUT);
    }
    mark = 10;
    lcd.clear();
    Serial.begin(115200);
    }

    void loop() {

    {INPUTPINS();} //Check the "button pressed" section
    {LCDMODE();} // Sets up the LCD for the mode it's in (From the rotary switch)
    {ROTARYS();} // go and check the rotary encoder
    {ROTARYSAUTO();} // go and check the rotary encoder QNH
    if (Serial.available()) { // now lets check the serial buffer for any input data
    CodeIn = getChar();
    if (CodeIn == '=') {EQUALS();}// The first identifier is "="
    if (CodeIn == '<') {LESSTHAN();}// The first identifier is "<"
    if (CodeIn == '/') {SLASH();}// The first identifier is "/" (Annunciators)
    if (CodeIn == '?') {QUESTION();}// QNH void

    } // end of serial available
    }// edn of void loop

    char getChar()// Get a character from the serial buffer
    {
    while(Serial.available() == 0);// wait for data
    return((char)Serial.read());// Thanks Doug
    }//end of getchar

    void ROTARYSAUTO() { //rotories from QNH
    R =(quad2.position()/2); //QNH
    if (R != Rold) { // checks to see if it different
    (Rdif = (R-Rold));// finds out the difference
    if (Rdif == 1) Serial.println ("C25");//up
    if (Rdif == -1) Serial.println ("C26"); //down
    Rold = R; // overwrites the old reading with the new one.
    }
    if (quad2.position() > 1000){ // zero the rotary encoder count if too high or low

    }
    if (quad2.position() < -1000){

    }

    }

    void LESSTHAN(){ // The first identifier was "<"
    CodeIn = getChar(); // Get the second identifier
    switch(CodeIn) {// Now lets find what to do with it
    case 'P'://indicated speed
    spd = "";
    spd += getChar();
    spd += getChar();
    spd += getChar();


    if (spd != spdold) {

    delay(11);
    lcd.setCursor(0, 0);
    delay (11);
    lcd.print(spd);
    spdold = spd;
    }
    break;
    case 'D'://indicated alt
    alt = "";
    alt += getChar();
    alt += getChar();
    alt += getChar();
    alt += getChar();
    alt += getChar();

    if (alt != altold) {

    delay(11);
    lcd.setCursor(4, 0);
    delay (11);
    lcd.print(alt);
    altold = alt;
    }
    break;
    case 'A': // found the second identifier (the "Gear nose")
    gearM = "";
    gearM += getChar();// get first charactor (Nose gear)
    if (gearM == "1"){digitalWrite(54, HIGH);}else{digitalWrite(54, LOW);}//Nose gear
    gearM += getChar(); // get the second charactor (gear left)
    if (gearM.endsWith("5")){digitalWrite(57, HIGH);}else{digitalWrite(57, LOW);}//left gear
    break;
    case 'B': // found the second identifier (the "Gear left")
    gearR = "";
    gearR += getChar();// get first charactor (Nose gear)
    if (gearR == "1"){digitalWrite(55, HIGH);}else{digitalWrite(55, LOW);}//Nose gear
    gearR += getChar(); // get the second charactor (gear left)
    if (gearR.endsWith("5")){digitalWrite(58, HIGH);}else{digitalWrite(58, LOW);}//left gear
    break;
    case 'C': // found the second identifier (the "Gear fight")
    gearL = "";
    gearL += getChar();// get first charactor (Nose gear)
    if (gearL == "1"){digitalWrite(56, HIGH);}else{digitalWrite(56, LOW);}//Nose gear
    gearL += getChar(); // get the second charactor (gear left)
    if (gearL.endsWith("5")){digitalWrite(59, HIGH);}else{digitalWrite(59, LOW);}//left gear
    break;
    }

    }// end of lessthen void

    void SLASH(){ // The first identifier was "/" (Annunciator)
    CodeIn = getChar(); // Get another character
    switch(CodeIn) {// Now lets find what to do with it
    case 'B'://Found the second identifier
    AnunB = String(getChar());// get state if /B (Overspeed flaps)
    if (AnunB == "1"){
    if (AnunBx != "3"){// checks it's not flashing
    digitalWrite(60, HIGH);
    delay(11);
    digitalWrite(65, HIGH);}}
    else{digitalWrite(60, LOW);
    AnunBx = "0";
    digitalWrite(65, LOW);}
    break;

    case 'C':
    AnunC = String(getChar());// get state if /C (Overspeed gear)
    if (AnunC == "1"){
    if (AnunCx != "3"){
    digitalWrite(61, HIGH);
    delay(11);
    digitalWrite(65, HIGH);}}
    else{digitalWrite(61, LOW);
    AnunCx = "0";
    digitalWrite(65, LOW);}
    break;

    case 'D':
    AnunD = String(getChar());// get state if /D (Overspeed frame)
    if (AnunD == "1"){
    if (AnunDx != "3"){
    digitalWrite(62, HIGH);
    delay(11);
    digitalWrite(65, HIGH);}}
    else{digitalWrite(62, LOW);
    AnunDx = "0";
    digitalWrite(65, LOW);}
    break;

    case 'E'://Found the second identifier
    AnunE = String(getChar());// get state if /E (Stall warning)
    if (AnunE == "1"){
    if (AnunEx != "3"){
    digitalWrite(63, HIGH);
    delay(11);
    digitalWrite(65, HIGH);}}
    else{digitalWrite(63, LOW);
    AnunEx = "0";
    digitalWrite(65, LOW);}
    break;

    case 'H':
    AnunH = String(getChar());// get state if /H (Low fuel)
    if (AnunH == "1"){
    if (AnunHx != "3"){
    digitalWrite(64, HIGH);
    delay(11);
    digitalWrite(65, HIGH);}}
    else{digitalWrite(64, LOW);
    AnunHx = "0";
    digitalWrite(65, LOW);}
    break;
    }//end of switch
    }//end of slash

    void LCDMODE(){
    if (active != activeold)
    activeold = active;
    if (digitalRead(14)==0 and active != 14) { // Sets up the LCD when switching to Com1)
    lcd.setCursor(0, 2);
    delay (11);
    lcd.print("Com.1 ");
    lcd.setCursor(9, 2);
    delay (11);
    lcd.print(com1);
    lcd.setCursor(0, 3);
    delay (11);
    lcd.print(" s/b ");
    lcd.setCursor(9, 3);
    delay (11);
    lcd.print(com1sb);
    active = 14;
    }

    if (digitalRead(15)==0 and active != 15) { // Sets up the LCD when switching to Com2)
    lcd.setCursor(0, 2);
    delay (11);
    lcd.print("Com.2 ");
    lcd.setCursor(9, 2);
    delay (11);
    lcd.print(com2);
    lcd.setCursor(0, 3);
    lcd.print(" s/b ");
    lcd.setCursor(9, 3);
    delay (11);
    lcd.print(com2sb);
    active = 15;
    }

    if (digitalRead(16)==0 and active != 16) { // Sets up the LCD when switching to Nav1)
    lcd.setCursor(0, 2);
    delay (11);
    lcd.print("Nav.1 ");
    lcd.setCursor(9, 2);
    delay (11);
    lcd.print(nav1);
    lcd.setCursor(0, 3);
    lcd.print(" s/b ");
    lcd.setCursor(9, 3);
    delay (11);
    lcd.print(nav1sb);
    active = 16;
    }
    if (digitalRead(17)==0 and active != 17) { // Sets up the LCD when switching to Nav2)
    lcd.setCursor(0, 2);
    delay (11);
    lcd.print("Nav.2 ");
    lcd.setCursor(9, 2);
    delay (11);
    lcd.print(nav2);
    lcd.setCursor(0, 3);
    lcd.print(" s/b ");
    lcd.setCursor(9, 3);
    delay (11);
    lcd.print(nav2sb);
    active = 17;
    }
    if (digitalRead(1==0 and active != 1 { // Sets up the LCD when switching to ADF)
    lcd.setCursor(0, 2);
    delay (11);
    lcd.print("ADF ");
    lcd.setCursor(9, 2);
    delay (11);
    lcd.print(adf);
    lcd.print(" ");
    lcd.setCursor(0, 3);
    lcd.print(" ");
    if (mark == 9 ){mark = 10;}
    lcd.setCursor(mark, 3);
    lcd.print("-");
    active = 18;
    }
    if (digitalRead(19)==0 and active != 19) { // Sets up the LCD when switching to DME)
    lcd.setCursor(0, 2);
    delay (11);
    lcd.print("DME1 ");
    lcd.setCursor(9, 2);
    delay (11);
    lcd.print(dme1);
    lcd.print(" ");
    lcd.setCursor(0, 3);
    lcd.print("DME2 ");
    lcd.setCursor(9, 3);
    delay (11);
    lcd.print(dme2);
    active = 19;
    }
    if (digitalRead(20)==0 and active != 20) { // Sets up the LCD when switching to XPDR)
    lcd.setCursor(0, 2);
    delay (11);
    lcd.print("XPonder ");
    lcd.setCursor(9, 2);
    delay (11);
    lcd.print(xpdr);
    lcd.print(" ");
    lcd.setCursor(0, 3);
    lcd.print(" ");
    lcd.setCursor(mark, 3);
    lcd.print("-");
    active = 20;
    }


    }// end of LCDmode

    void QUESTION() { // QHNH void get the first charictor
    delay (11);
    CodeIn = getChar(); // Set another charictor
    switch(CodeIn) {// Now lets find what to do with it
    case 'k'://Found the reading "Com1"
    QNH = "";
    QNH += getChar();
    QNH += getChar();
    QNH += getChar();
    QNH += getChar();
    QNH += getChar();

    if (QNH != QNHold) {
    delay (11);
    lcd.setCursor(15, 0);
    delay (11);
    lcd.print(QNH);
    QNHold = QNH;
    }

    break;
    }
    }

    void EQUALS(){ // The first identifier was "="
    delay (11);
    CodeIn = getChar(); // Get another character
    switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the reading "Com1"
    com1 = "";
    com1 += getChar();
    com1 += getChar();
    com1 += getChar();
    com1 += getChar();
    com1 += getChar();
    com1 += getChar();
    com1 += getChar();
    if (com1 != com1old && digitalRead(14) == LOW) {
    delay (11);
    lcd.setCursor(9, 2);
    delay (11);
    lcd.print(com1);
    com1old = com1;
    }
    break;
    case 'B': // Found the reading "Com1 s/b"
    com1sb = "";
    com1sb += getChar();
    com1sb += getChar();
    com1sb += getChar();
    com1sb += getChar();
    com1sb += getChar();
    com1sb += getChar();
    com1sb += getChar();
    if (com1sb != com1sbold && digitalRead(14) == LOW ){
    delay (11);
    lcd.setCursor(9, 3);
    delay (11);
    lcd.print(com1sb);
    com1sbold = com1sb;
    }
    break;
    case 'C': // Found the reading "Com2"
    com2 = "";
    com2 += getChar();
    com2 += getChar();
    com2 += getChar();
    com2 += getChar();
    com2 += getChar();
    com2 += getChar();
    com2 += getChar();
    if (com2 != com2old && digitalRead(15) == LOW) {
    lcd.setCursor(9, 2);
    delay (11);
    lcd.print(com2);
    com2old = com2;
    }
    break;
    case 'D': // Found the reading "Com2 s/b"
    com2sb = "";
    com2sb += getChar();
    com2sb += getChar();
    com2sb += getChar();
    com2sb += getChar();
    com2sb += getChar();
    com2sb += getChar();
    com2sb += getChar();
    if (com2sb != com2sbold && digitalRead(15) == LOW) {
    lcd.setCursor(9, 3);
    delay (11);
    lcd.print(com2sb);
    com2sbold = com2sb;
    }
    break;
    case 'E': // Found the reading "Nav1"
    delay (11);
    nav1 = "";
    nav1 += getChar();
    nav1 += getChar();
    nav1 += getChar();
    nav1 += getChar();
    nav1 += getChar();
    nav1 += getChar();
    nav1 += (" "); //pads it up to 8 caracters
    if (nav1 != nav1old && digitalRead(16) == LOW) {
    lcd.setCursor(9, 2);
    delay (11);
    lcd.print(nav1);
    nav1old = nav1;
    }
    break;
    case 'F': // Found the reading "Nav1 s/b"
    nav1sb = "";
    nav1sb += getChar();
    nav1sb += getChar();
    nav1sb += getChar();
    nav1sb += getChar();
    nav1sb += getChar();
    nav1sb += getChar();
    nav1sb += (" "); //pads it up to 8 caracters
    if (nav1sb != nav1sbold && digitalRead(16) == LOW) {
    lcd.setCursor(9, 3);
    delay (11);
    lcd.print(nav1sb);
    nav1sbold = nav1sb;
    }
    break;
    case 'G': // Found the reading "Nav2"
    delay (11);
    nav2 = "";
    nav2 += getChar();
    nav2 += getChar();
    nav2 += getChar();
    nav2 += getChar();
    nav2 += getChar();
    nav2 += getChar();
    nav2 += (" "); //pads it up to 8 caracters
    if (nav2 != nav2old && digitalRead(17) == LOW) {
    lcd.setCursor(9, 2);
    delay (11);
    lcd.print(nav2);
    nav2old = nav2;
    }
    break;
    case 'H': // Found the reading "Nav2 s/b"
    nav2sb = "";
    nav2sb += getChar();
    nav2sb += getChar();
    nav2sb += getChar();
    nav2sb += getChar();
    nav2sb += getChar();
    nav2sb += getChar();
    nav2sb += (" "); //pads it up to 8 caracters
    if (nav2sb != nav2sbold && digitalRead(17) == LOW) {
    lcd.setCursor(9, 3);
    delay (11);
    lcd.print(nav2sb);
    nav2sbold = nav2sb;
    }
    break;
    case 'I': // Found the reading "ADF"
    adf = "";
    adf += getChar();
    adf += getChar();
    adf += getChar();
    adf += getChar();
    adf += getChar();
    adf += getChar();
    adf += (" "); //pads it up to 8 caracters
    if (adf != adfold && digitalRead(1 == LOW) {
    lcd.setCursor(9, 2);
    delay (11);
    lcd.print(adf);
    adfold = adf;
    }
    break;
    case 'J': // Found the reading "XPDR"
    delay (11);
    xpdr = "";
    xpdr += getChar();
    xpdr += getChar();
    xpdr += getChar();
    xpdr += getChar();
    xpdr += (" "); //pads it up to 8 caracters
    if (xpdr != xpdrold && digitalRead(20) == LOW) {
    lcd.setCursor(9, 2);
    delay (11);
    lcd.print(xpdr);
    xpdrold = xpdr;
    }
    break;
    case 'K': // Found the reading "DME1"
    delay (11);
    dme1 = "";
    dme1 += getChar();
    dme1 += getChar();
    dme1 += getChar();
    dme1 += getChar();
    dme1 += getChar();
    dme1 += (" "); //pads it up to 8 caracters
    if (dme1 != dme1old && digitalRead(19) == LOW) {
    lcd.setCursor(9, 2);
    delay (11);
    lcd.print(dme1);
    dme1old = dme1;
    }
    break;
    case 'L': // Found the reading "DME2"
    delay (11);
    dme2 = "";
    dme2 += getChar();
    dme2 += getChar();
    dme2 += getChar();
    dme2 += getChar();
    dme2 += getChar();
    dme2 += (" "); //pads it up to 8 caracters
    if (dme2 != dme2old && digitalRead(19) == LOW) {
    lcd.setCursor(9, 3);
    delay (11);
    lcd.print(dme2);
    dme2old = dme2;
    }
    break;

    }
    }

    void ROTARYS() {//now the bit for the rotary encoder input
    X = (quad1.position()/2);
    if (X != Xold) { // checks to see if it different
    (Xdif = (X-Xold));// finds out the difference

    if (active == 14){// Com1 rotary encoder output
    if (Xdif == 1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A01");
    }
    else Serial.println("A03");
    }
    if (Xdif == -1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A02");
    }
    else Serial.println("A04");
    }
    }
    if (active == 15){// Com2 rotary encoder output
    if (Xdif == 1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A07");
    }
    else Serial.println("A09");
    }
    if (Xdif == -1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A08");
    }
    else Serial.println("A10");
    }
    }
    if (active == 16){// Nav1 rotary encoder output
    if (Xdif == 1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A13");
    }
    else Serial.println("A15");
    }
    if (Xdif == -1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A14");
    }
    else Serial.println("A16");
    }
    }
    if (active == 17){// Nav2 rotary encoder output
    if (Xdif == 1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A19");
    }
    else Serial.println("A21");
    }
    if (Xdif == -1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A20");
    }
    else Serial.println("A22");
    }
    }
    if (active == 1{// ADF rotary encoder output
    if (digitalRead(10)==0 ) {
    if (Xdif == 1) {
    mark = (mark - 1);
    active = 2;
    if (mark == 13) mark =12;
    }
    if (Xdif == -1){
    mark = (mark + 1);
    active = 2;
    if (mark == 13) mark =14;
    }
    if (mark > 14) mark = 14;
    if (mark < 10) mark = 10;
    }
    else{
    if (Xdif == 1) {
    if (mark == 10) {
    Serial.println("A29");
    }
    if (mark == 11) {
    Serial.println("A30");
    }
    if (mark == 12) {
    Serial.println("A31");
    }
    if (mark == 14) {
    Serial.println("A32");
    }
    }
    if (Xdif == -1){
    if (mark == 10){
    Serial.println("A25");
    }
    if (mark == 11){
    Serial.println("A26");
    }
    if (mark == 12){
    Serial.println("A27");
    }
    if (mark == 14){
    Serial.println("A28");
    }
    }
    }
    }
    if (active == 20){// Xponder rotary encoder output
    if (digitalRead(10)==0 ) {
    if (Xdif == 1) {
    mark = (mark - 1);
    active = 2;
    }
    if (Xdif == -1){
    mark = (mark + 1);
    active = 2;
    }
    if (mark > 12) mark = 12;
    if (mark < 9) mark = 9;
    }
    else{
    if (Xdif == 1) {
    if (mark == 9) {
    Serial.println("A38");
    }
    if (mark == 10) {
    Serial.println("A39");
    }
    if (mark == 11) {
    Serial.println("A40");
    }
    if (mark == 12) {
    Serial.println("A41");
    }
    }
    if (Xdif == -1){
    if (mark == 9){
    Serial.println("A34");
    }
    if (mark == 10){
    Serial.println("A35");
    }
    if (mark == 11){
    Serial.println("A36");
    }
    if (mark == 12){
    Serial.println("A37");
    }
    }
    }
    }


    if (quad1.position() > 1000){ // zero the rotary encoder count if too high or low
    quad1.position(0);
    }
    if (quad1.position() < -1000){
    quad1.position(0);
    }




    Xold = X; // overwrites the old reading with the new one.
    }
    }// end of rotarys

    void INPUTPINS(){
    stringnewstate = "";
    for (int pinNo = 10; pinNo <= 37; pinNo++){// checks all the pins 10 to 53
    pinStateSTR = String(digitalRead(pinNo));
    oldpinStateSTR = "";
    oldpinStateSTR += String(stringoldstate.charAt(pinNo - 10));
    if (pinStateSTR != oldpinStateSTR) {// yes it's different
    if (pinNo == 11 and pinStateSTR == "0") { //Change-over button is pressed
    if (active == 14) Serial.println("A06");//com1
    if (active == 15) Serial.println("A12");//com2
    if (active == 16) Serial.println("A18");//nav1
    if (active == 17) Serial.println("A24"); //nav2
    if ( active == 1{ //adf
    mark = (mark + 1);
    if (mark == 13){
    mark = 14;
    }// sort out for piont in ADF
    active = 1;
    if (mark > 14)mark = 10;
    }
    if (active == 20){ //xponder
    mark = (mark + 1);
    if (mark == 13){
    mark = 9;
    }// sort out for length Xponder
    active = 1;
    if (mark > 12)mark = 12;
    }
    }// end of pin 11 sortout
    if (pinNo == 21 && pinStateSTR == "0"){Serial.println ("C01");} // Gear UP
    if (pinNo == 21 && pinStateSTR == "1"){Serial.println ("C02");} // Gear DOWN


    // Add more "Simconnect direct" codes here.
    // now the "keys" bit ,,, notice the "26" in line above and also in line below.
    if (pinNo > 21){ // start of "Keys" bit
    Serial.print ("D");
    if (pinNo < 10) Serial.print ("0");
    Serial.print (pinNo);
    Serial.println (pinStateSTR);

    } // end of "Keys" bit
    }// end of "yes it's different"
    stringnewstate += pinStateSTR;
    }
    stringoldstate = stringnewstate;
    delay(11);
    }// end of inputpins

  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: Barometric presure

    Perhaps this page may be of help regarding math.
    Look a little down the page: Math is hard, let's try programming!

    http://www.ladyada.net/learn/arduino/lesson4.html
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

  3. #3
    75+ Posting Member
    Join Date
    Feb 2010
    Location
    London
    Posts
    87
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Barometric presure

    noo not really but thank you for you help

  4. #4
    75+ Posting Member
    Join Date
    Feb 2010
    Location
    London
    Posts
    87
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Barometric presure

    now I think I know the part of the problem
    so the data in link2fs that are put on the display,barometric presure in my case
    is of a String type.So basicaly a sting of charactors.So as I undestand 29.92 is not the sam as value of 29.92.
    o how to I multiply a sting,or how do I show the result of multiplication of 33.638 * string

  5. #5
    150+ Forum Groupie
    Join Date
    Apr 2011
    Location
    United States of America
    Posts
    232
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Barometric presure

    You're on to it.

    This example was pulled from my stepper motor ino Rev 1.03 :

    case 'L':
    for (int i = 0; i < 4; i++) {delay(1); Mstep += getChar(); }
    for (int i = 0; i < 4; i++) {delaystr += getChar();}
    stepi = Mstep.toInt();
    delayi = delaystr.toInt();
    Left();

  6. #6
    75+ Posting Member vikingsraven's Avatar
    Join Date
    Dec 2012
    Location
    UK
    Posts
    89
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Barometric presure

    hopefully it s a typo or this forum setup
    but
    #include "math.h"
    #include "Quadrature.h"
    #include
    this wont do anything
    should be
    Code:
    
    #include< Quadrature.h> 
    #include < math.h>
    also missing the #include < LiquidCrystal.h>
    remove the spaces at the front its the only way i can get them to stay on this post! BBC uses < >
    
    theres also a lot of ) missing from your if statements.
    im just going to run the code now these are sorted and see whats up!
    also QNH is a String, that means its basically one byte of memory for each character plus 2 extra for \0 which shows its a string.

    You wont be able to multiply that straight of you need to convert the String to a float( a variable that has decimal places).
    It would have to change to a char first ( this is like a string but no \0 at the end)
    Code:
    char floatbuf[6];  // this is where the string is going to be dumped as a char so the number needs to be big enough for the number of characters
      QNH.toCharArray(floatbuf,5); //This will convert QNH to a char and put it into floatbuf which is 5 long ( arrays start with 0 so 0-5 =6)
      float f = atof(floatbuf);   // this will convert floatbuf to a float variable called 'f'.
    lcd.print(f * 33.638);
    this should do the trick!

    Last edited by vikingsraven; 01-25-2014 at 09:42 AM. Reason: changed value at the end

  7. Likes BuzziBi liked this post