How to index Port variable


Results 1 to 5 of 5

Threaded View

  1. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Code:
    LED var PORTD ' Alias PORTD.0 to LED
    i VAR byte
    
    mainloop:
    for i = 0 to 7 
    
    High LED ' Turn on LED connected to PORTD.i
    Pause 250 ' Delay for .5 seconds
    
    Low LED' Turn off LED connected to PORTD.i
    Pause 750 ' Delay for .5 seconds
    
    Next i
    Goto mainloop ' Go back to loop and blink LED forever
    
    End
    Hi Jpadin1,
    Byte is a bit array, lose the modifier and it should do what you want see snippet above
    or
    Code:
    HIGH LED[i]
    pause 750
    LOW LED[i]
    pause 750
    Check this link out:
    http://www.picbasic.co.uk/forum/showthread.php?t=8876
    Last edited by Archangel; - 14th February 2010 at 17:58.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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. accessing ports pins using an index variable
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th March 2008, 20: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. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Question on assigning pin port to variable
    By khufumen in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 1st June 2005, 22:25

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