Results 1 to 5 of 5
  1. #1
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    May 2015
    Location
    Belgium
    Posts
    6
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Arduino Uno + MCP23017 to link2fs

    I need some help getting the MCP23017 which is connected to an Arduino Uno working for link2fs.
    I've created a very small test script but nothing is being registered on link2fs. LED 13 on the arduino works when pressing the button though.
    link2fs is setup correctly as I did other tests without the MCP23017 successfully.

    #include
    #include "Adafruit_MCP23017.h"

    Adafruit_MCP23017 mcp;

    void setup() {

    mcp.begin(); // use default address 0
    mcp.pinMode (0, INPUT); mcp.pullUp (0, HIGH);
    pinMode(13, OUTPUT);
    }
    void loop() {
    digitalWrite(13, mcp.digitalRead(0));
    if (!mcp.digitalRead(0)){Serial.println ("C02");}
    }


    The setup is very simple, the button is connected on the MCP23017 pin 21 (0 when using adafruit) and when pressed led 13 on the arduino (which is on by default) goes out.

    Any advise on why the landing gear is not dropping or nothing appears on the monitoring side of link2fs?

  2. #2
    25+ Posting Member
    Join Date
    May 2014
    Location
    Bulgaria and United Kingdom
    Posts
    56
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino Uno + MCP23017 to link2fs

    In the sketch above you forgot to start serial port.
    Serial.begin(115200);

  3. #3
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    May 2015
    Location
    Belgium
    Posts
    6
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino Uno + MCP23017 to link2fs

    thanks trakon! I can't believe I've missed that one
    When pressing the button it sends more then 1 signal through, is there any way to limit the keypresses to 1 every .5 sec for example?

    I've tried with a delay:


    if (!mcp.digitalRead(0)){Serial.println ("A06");}
    delay (100);
    but still link2fs gets 2 signals (or more) for each press.

  4. #4
    25+ Posting Member
    Join Date
    May 2014
    Location
    Bulgaria and United Kingdom
    Posts
    56
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino Uno + MCP23017 to link2fs

    Hi,
    Certainly there is. Think of the following – the way you wrote it: if ( ! digitalRead(0) { } , you making Arduino to trigger event every time when pin
    goes from HIGH to LOW, but also when it goes from LOW to HIGH and that mean:
    1- when you are pressing the button down
    2- - when you releasing it back
    3- when button bounces up-doun-up-down

    Try the following approach:

    boolean button, buttonOld=HIGH;

    void setup() { }

    void loop() {

    button=digitalRead(2);
    if(button != buttonOld) { delay(10); button=digitalRead(2);
    if(button == LOW) { Serial.println ("A06"); } buttonOld=button; }


    }

  5. #5
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    May 2015
    Location
    Belgium
    Posts
    6
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Arduino Uno + MCP23017 to link2fs

    awesome, it works!

    I've updated the code for my needs as such, works like a charm:

    #include
    #include "Adafruit_MCP23017.h"

    Adafruit_MCP23017 mcp;

    boolean button, buttonOld=HIGH;

    void setup() {
    Serial.begin(115200);
    mcp.begin(); // use default address 0

    mcp.pinMode (0, INPUT); mcp.pullUp (0, HIGH);
    pinMode(13, OUTPUT);
    }
    void loop() {
    // digitalWrite(13, mcp.digitalRead(0));
    // if (!mcp.digitalRead(0)){Serial.println ("A06");}
    button=mcp.digitalRead(0);
    if(button != buttonOld) { delay(10); button=mcp.digitalRead(0); if(button == LOW) { Serial.println ("A06"); } buttonOld=button; }

    }// end of inputpins