FOR...NEXT strange counting


Results 1 to 14 of 14

Threaded View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938

    Default FOR...NEXT strange counting

    Hello,

    I can't figure out how the FOR...NEXT count works.

    First my code, then my question.

    Code:
    ...
    Duty VAR BYTE
    Duty = 0
    
    if duty = 0 then
       FOR Duty = 0 TO 254
          HPWM 1, Duty, 1000
          lcdout Dec Duty 'First read of "Duty"
          PAUSE 5
       NEXT
       lcdout Dec Duty 'Second read of "Duty"
    endif
    ...
    At the end of the FOR...NEXT execution, first read of Duty = 254. Right after the "NEXT" command, the second read of the variable Duty = 255.

    Why is this!?
    Last edited by flotulopex; - 7th October 2006 at 17:05.
    Roger

Similar Threads

  1. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 04:52
  2. Remain counting while sending out a pulse
    By ultiblade in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th January 2007, 15:51
  3. Strange behaviour from PIC16F877 on TMR0
    By mikebar in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 19th August 2006, 01:31
  4. continious counting process (capture)
    By asynch in forum General
    Replies: 1
    Last Post: - 17th February 2006, 07:42
  5. Strange ASM file
    By barkerben in forum General
    Replies: 2
    Last Post: - 29th November 2004, 18:54

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