accessing ports pins using an index variable


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    If I am getting it right, this should be it.
    But, this should not be this easy, should it?
    I must be wrong then.


    Code:
    <font color="#000000">TRISA = <font color="#FF0000"><b>%11111
    
    </b></font>MyPort <font color="#000080"><b>VAR </b></font>PORTA
    Index  <font color="#000080"><b>VAR BYTE
    
    </b></font>Start:
    
        <font color="#000080"><b>FOR </b></font>Index = <font color="#FF0000"><b>0 </b></font><font color="#000080"><b>TO </b></font><font color="#FF0000"><b>5   </b></font><font color="#000080"><i>' Scan MyPort (PORTA) pins.
          </i><b>IF </b></font>MyPort.<font color="#FF0000"><b>0</b></font>[Index] = <font color="#FF0000"><b>0 </b></font><font color="#000080"><b>THEN BRANCH </b></font>Index,[IntA0,IntA1,IntA2,IntA3,IntA4,IntA5]    
        <font color="#000080"><b>NEXT </b></font>Index
        
        <font color="#000080"><i>' Above routine is the same as
        ' IF MyPort.0 = 0 then IntA0
        ' IF MyPort.1 = 0 then IntA1
        ' IF MyPort.2 = 0 then IntA2
        ' IF MyPort.3 = 0 then IntA3
        ' IF MyPort.4 = 0 then IntA4
        ' IF MyPort.5 = 0 then IntA5                    
        
    </i><b>GOTO </b></font>Start
    
    IntA0:
    
    <font color="#000080"><i>'Do your stuff or PORTA.0 here.
    
        </i><b>GOTO </b></font>Start
    
    IntA1:
    
    <font color="#000080"><i>'Do your stuff or PORTA.1 here.
    
        </i><b>GOTO </b></font>Start
    
    IntA2:
    
    <font color="#000080"><i>'Do your stuff or PORTA.2 here.
    
        </i><b>GOTO </b></font>Start
    
    
    IntA3:
    
    <font color="#000080"><i>'Do your stuff or PORTA.3 here.
    
        </i><b>GOTO </b></font>Start
    
    
    IntA4:
    
    <font color="#000080"><i>'Do your stuff or PORTA.4 here.
    
        </i><b>GOTO </b></font>Start
    
    
    IntA5:
    
    
    <font color="#000080"><i>'Do your stuff or PORTA.5 here.
    
        </i><b>GOTO </b></font>Start
    
    
    
    <font color="#000080"><b>END
    
    </b></font>
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    thank you very much for your help guys

Similar Threads

  1. EEPROM Variables (EE_Vars.pbp)
    By Darrel Taylor in forum Code Examples
    Replies: 79
    Last Post: - 26th October 2012, 00:06
  2. How to index Port variable
    By jpadin1 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th February 2010, 10:36
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. Accessing pins with a variable
    By Desterline in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 20th August 2004, 16:03
  5. Accessing ports ( Melanie )
    By anj in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th March 2004, 20:52

Members who have read this thread : 0

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