Results 1 to 3 of 3
  1. #1
    10+ Posting Member
    Join Date
    Feb 2011
    Location
    Williamson, GA, USA
    Posts
    23
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Mycockpit.org declaring Analog pins as output

    {
    I need some advice with my mega 2650 on using Analog pins as outputs. Do I refer to these pins as A0-A14 in the code or 54-69? I am not getting any results with my flap lights using my version of Jim's starter 2.pde. In fact I noticed all the examples (that I have seen) use the lower numbers as outputs, does this really matter? I do suspect the way I have coded my pins might be a problem although it loaded ok. Thanks for any advice.
    Lee
    }
    We were meant to fly, even with a computer.

  2. #2
    Just muddling through...


    John UK's Avatar
    Join Date
    May 2012
    Location
    United Kingdom
    Posts
    25
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: declaring Analog pins as output

    Quote Originally Posted by LeeGlen View Post
    {
    I need some advice with my mega 2650 on using Analog pins as outputs. Do I refer to these pins as A0-A14 in the code or 54-69? I am not getting any results with my flap lights using my version of Jim's starter 2.pde. In fact I noticed all the examples (that I have seen) use the lower numbers as outputs, does this really matter? I do suspect the way I have coded my pins might be a problem although it loaded ok. Thanks for any advice.
    Lee
    }
    Did you change the following line in the starter code for your mega Card (highlighted in red):
    Code:
    stringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111"; // Gives the "keys old" string a value
      // Setup the pins as inputs as used by "Keys" (For the "Keys" program avoid actually using Pin 13 as an input ,, long story)
      for (int doutPin = 8; doutPin <= 19; doutPin++)  // if you have a Mega card and want to use all the pins ,, change the 19 to 69
    It should read as follows or you wont be able to use the pins that the mega has that the Uno dosn't (highlighted in green):-

    Code:
    stringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111"; // Gives the "keys old" string a value
      // Setup the pins as inputs as used by "Keys" (For the "Keys" program avoid actually using Pin 13 as an input ,, long story)
      for (int doutPin = 8; doutPin <= 69; doutPin++)  // if you have a Mega card and want to use all the pins ,, change the 19 to 69
    It is an easy thing to miss. The reason you see most code using lower numbers is probably because the code is designed around a Uno and not a Mega.

  3. #3
    10+ Posting Member
    Join Date
    Feb 2011
    Location
    Williamson, GA, USA
    Posts
    23
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: declaring Analog pins as output

    Thanks John, I just checked my pin modes and found I had set pins 30-57 as output instead of "input" and 58-69 as inputs instead of "outputs." Duhhhh! All the pins <=29 are reserved for encoders. And yes I did change the 19 to 69. I'm trying to learn as I go and thanks to Jim for his examples and to those who are willing to help unravel this code.
    I shall return!
    regards Lee
    We were meant to fly, even with a computer.