Is it allowed to change pin reference within a subroutine?


Results 1 to 19 of 19

Threaded View

  1. #1
    Join Date
    Jun 2016
    Posts
    60

    Default Is it allowed to change pin reference within a subroutine?

    I am using three temperature sensors wired to three different pins (portB.5 - portB.6 and portB.7)

    Now I am using three different sub-routine to read the sensors value, but since all the routine have the same code, I would like to have one single routine for all the three sensors, just changing the alias reference within the sub-routine. In other words, something like this:

    Read_Sensors:
    If index = 0 then return
    If index > 3 then return
    If index = 1 then use_pin = portB.5
    If index = 2 then use_pin = portB.6
    If index = 3 then use_pin = portB.7

    Read sensor using "use_pin"

    Load variable[index]

    Return

    The above code could it work?

    If the answer is yes, how do I declare the alias "use_pin"? (Byte or Word)

    Alberto
    Last edited by Alberto; - 31st January 2017 at 01:29.

Similar Threads

  1. Replies: 8
    Last Post: - 21st March 2015, 17:21
  2. 10F222 Wake on pin change
    By AvionicsMaster1 in forum PBP3
    Replies: 11
    Last Post: - 9th January 2014, 19:14
  3. Reference a port pin from a variable
    By JimAvanti in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th February 2012, 20:18
  4. Interrupt-on-Change-pin!
    By PICante in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th February 2009, 20:22
  5. HELP !!! How change the voltage of a pin ????
    By stormdacta in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 21st August 2007, 20:55

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts