PDA

View Full Version : For ... Next



micro
- 6th March 2006, 15:11
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 ?

DynamoBen
- 6th March 2006, 16:54
Try this:

i var byte

main

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

goto main

sayzer
- 6th March 2006, 16:57
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.


-------------

paul borgmeier
- 6th March 2006, 23:40
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