Menu

Old program doesn't work on V98.06

Help
2020-01-25
2020-01-26
  • Jack Hoffnung

    Jack Hoffnung - 2020-01-25

    An old simple program to read illumination on a photocell will no longer compile; the culprit is this:
    dir AN2 in. Code attached. Error message when compiling is:
    ToPost.gcb (17): Error: 2 is not a valid I/O pin or port
    If I replace dir AN2 with dir GPIO 0b00000100 , it compiles fine. I'm stumped.

     
  • Jack Hoffnung

    Jack Hoffnung - 2020-01-25

    Here's the code.

     
  • Chris Roper

    Chris Roper - 2020-01-25

    Hi Jack,

    The .dat file format was updated some time ago with a new set of tools and features and so may have changed for your device.

    The best solution is to change:

    #define sensor AN2                           ;output from sensor on AN2, pin 5
    dir AN2 in                                   ;make AN2 an input
    

    To read:

    #define sensor GPIO.2                   ;output from sensor on AN2, pin 5
    dir sensor in                                    ;make AN2 an input 
    

    Cheers
    Chris

     
  • Anobium

    Anobium - 2020-01-25

    'dir an2' should never have worked in the past. anX is, and always has been, a numeric constant somewhere between 0 ..29

    So, change code. As the error message is correct.

    And, you not need to set the dir, and, you should add ADC optimisation to your code.

     

    Last edit: Anobium 2020-01-25
  • Jack Hoffnung

    Jack Hoffnung - 2020-01-25

    Thanks for the helpful replies!

     
  • Jack Hoffnung

    Jack Hoffnung - 2020-01-26

    Only 2 things I would sugggest which might be helpful, one of which was in your initial reply.
    1. Indicate under ANX that X=0 to 29, corresponding to port pin numbers. (Same for pX and nY).
    2. Demonstrate in example code that ANX can be replaced by anything previously #define(d) equalling ANX.
    Thanks again.

     
  • Anobium

    Anobium - 2020-01-26

    The idea was to get you to do the changes based upon your experience.

    Editing in GitHub is very easy. You can ask to become a contributor (and edit the masters), or, you can clone and then submit for inclusion.

    The more people editing and revising will improve the Help.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.