+ Reply to Thread
Results 1 to 3 of 3
  1. #1

    Default bit position variable

    i have some code like this:
    '***********
    WriteByte var byte 'WriteByte holds the on off states for 8 LEDs
    LED32 var byte 'LED32 holds the bit position for LED32 on the pcb in the WriteByte byte

    LED32 = 3 ' bit3 in WriteByte, LED32 is connected to bit3 of a port expander chip, not a PIC pin

    WriteByte.3 = 0 'this turns on LED32 but is not very readable
    '*************

    but the above code is not very readable, i would like to write:
    WriteByte.LED32 = 0
    but above statement throws a compile error

    what is the best way to handle this ? sadly, i think i used to know, an array ?

  2. #2
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343

    Default Re: bit position variable

    Quote Originally Posted by dsicon View Post
    i have some code like this:
    '***********
    Code:
    WriteByte var byte    'WriteByte holds the on off states for 8 LEDs
    LED32 var byte         'LED32 holds the bit position for LED32 on the pcb in the WriteByte byte
    
    LED32 = 3                ' bit3 in WriteByte, LED32 is connected to bit3 of a port expander chip, not a PIC pin
    
    WriteByte.3 = 0         'this turns on LED32 but is not very readable
    '*************

    but the above code is not very readable, i would like to write:
    WriteByte.LED32 = 0
    but above statement throws a compile error

    what is the best way to handle this ? sadly, i think i used to know, an array ?
    I think this is what you are getting at.
    Code:
    WriteByte    VAR BYTE
    LED32        VAR WriteByte.3
    
    LED32 = 0
    But, lets say that this LED is actually attached to pin 3 of PORTB. In this case, you could use this:
    Code:
    LED32        VAR PORTB.3
    Or this:
    Code:
    WriteByte    VAR PORTB
    LED32        VAR WriteByte.3
    HTH

  3. #3

    Default Re: bit position variable

    you seem to be suggesting that this is simpler than i am making it

    you might be correct, let me play with this and get back to you and thanks for your response

Similar Threads

  1. User Position, Velocity & Time II (D1h)
    By dj.lambert in forum GPS
    Replies: 2
    Last Post: - 31st July 2009, 09:21
  2. Replies: 6
    Last Post: - 30th June 2008, 16:33
  3. Changing position of program code
    By aerostar in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 15th December 2006, 07:34
  4. how to know servo position on lcd?
    By macx75 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd March 2006, 22:52
  5. Read cursors position on LCD?
    By lab310 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 13th April 2005, 13:20

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