How can I use for next like PORTB.MYVARIABLE ???


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    obaskirt's Avatar
    obaskirt Guest


    Did you find this post helpful? Yes | No

    Red face

    Quote Originally Posted by mister_e
    Code:
    for LED=0 to 7
         HIGH LED
        PAUSE 500
        LOW LED
        PAUSE 500
        NEXT
    My problem is; I can not define PORTB.LED??? and in your example which port did you make high or low? For example, I connected 8 leds to PIC 16F84's PortB. How can you turn on then turn of these leds by using for next loop. Also you can do this by left and right shift operator but I am curious about how can this problem accomplish by using for-next loop. Thankss..

  2. #2
    MaurI's Avatar
    MaurI Guest


    Did you find this post helpful? Yes | No

    Default

    i var byte
    x var byte

    TRISB=0

    i=0
    begin
    For i=0 to 7

    Lookup i,[1,2,4,8,16,32,64,128],x
    PORTB=x
    Pause 200
    next i
    i=0
    goto begin

    end


    Well in this little sample there is For next so check it out!

    And don't use those High and Low if it is possible better use =0, =1 - it will save your code space
    Last edited by MaurI; - 2nd September 2005 at 11:55.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by obaskirt
    My problem is; I can not define PORTB.LED??? and in your example which port did you make high or low? For example, I connected 8 leds to PIC 16F84's PortB. How can you turn on then turn of these leds by using for next loop. Also you can do this by left and right shift operator but I am curious about how can this problem accomplish by using for-next loop. Thankss..
    low = 0 does the same thing as low portb.0. You can address portb 0-7 and portc 8-15 like this. I'm not sure if you can access other ports in this fashion or not though.

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