For ... Next


Closed Thread
Results 1 to 4 of 4

Thread: For ... Next

Hybrid View

  1. #1
    micro's Avatar
    micro Guest

    Default For ... Next

    i want to print numbres from 0 to 10 and display it on LCD as below


    I var byte

    main
    i=0
    for i=0 to 10

    serout 2,2,[#I]

    next I
    goto main

    but i note the first number will be 1 not 0, i tried to change idea as below

    I var byte
    Z var byte
    main
    z=0
    for i=0 to 10
    serout 2,2,[#z]
    z=z+1
    next I
    goto main

    but the problem still exist
    any idea to solve that ?

  2. #2
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    Try this:

    i var byte

    main

    for i=0 to 10
    serout 2,2,[DEC i]
    next i

    goto main

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


    Did you find this post helpful? Yes | No

    Cool

    Also try this.
    -----------------
    i var byte



    Main:

    i=0

    While i<11
    serout 2,2,[#i]
    i=i+1
    wend

    goto main

    -------------------------
    That is gonna be so fast.


    -------------
    Last edited by sayzer; - 6th March 2006 at 17:05.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  4. #4
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    micro,
    Your first command to print the 0 might be missed if you are not “idling high”.
    Add the following line
    PORTB.2 =1
    somewhere before your first SEROUT statement and all should be well with your original code. This line will cause pin 2 to idle high, which is required for T9600. Let us know how it turns out.

    Oh, you also should add a ":" to your first main so that it looks like main:

    Good Luck,

    Paul Borgmeier
    Salt Lake City, Utah
    USA

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