Hi David,
Code:
i VAR WORD
Main:
For i = 0 to 3 etc
LOOKUP i, [0, 1,2,3], GPIO
NEXT i
That will work for exercise purposes but in the above case there's really no need for the LOOKUP table. You can just as well write i directly to GPIO, you'd also want a PAUSE in there or it will count really fast, and don't forget to set the TRIS-register to make the pins in question outputs:
Code:
Main:
For i = 0 to 3
GPIO = i
Pause 500
NEXT i
0000 making the driver display '0'
0001 " " '1'
0010 " " '2'
0011 " " '3'
1000 " " '4'
Not quite, it will count (and display) 0, 1, 2 and 3 since 3 is what you have in your FOR statement. Actually i will get incremented one more time, to 4, but when that happens the code will jump to after the NEXT statement so the "4" will never make it to GPIO. (If that last thing didn't make sense never mind, the important thing is that it counts from 0 to 3.)
/Henrik.
Bookmarks