Joe -
The author is using a different method for telling the micro which pin to turn on or off. He's using an array. With this method you can minimize the amount of code needed, and hence the cleaner, tidier code. Let's walk through it with some more comments.
Code:
LED var Byte 'LED variable setup as byte
PortB = %00000000 'Initiate all port B pins to low
Trisb = %00000000 'Setup port b as all outputs
main: 'Label for beginning of main loop
' *********** Light LEDs in right direction
for led = 0 to 7 'Loop through all LEDs
This variable not only counts up, but also indicates which pin
should turn on or off.
portB.0[LED] = 1 'Set each pin of portb high (5 volts) which turns the LED on
The first time through the loop, LED = 0. So the statement
PORTB.0[LED] = 1 is the same as writing portB.0 = 1.
The next time through the loop, LED will = 1, which is the same
as writing portB.1 = 1 and so on.
Think of it as turn on PORTB.0 + the value in the LED variable.
pause 1000 'Pause 1000 milliseconds (1 second) with LED on
Now look at Sayzer's post and it should make much more sense.
Bookmarks