Having a look at the sourcecode, you can see that we have now done away with individually setting a certain bit, holding that bit on with the delay, then clearing that bit. Now we are sending a full BYTE of data to PORTB every time we want the led to move one space. This is achieved by use of the MOVLW and MOVWF instructions. By using binary digits (denoted by the b' ' ) it is really easy to see what LED's will be ON and what LED's will be OFF. for example - if we wrote b'00000001' we can immediately see that all LED's will be OFF except for the right most LED which will be on. That's what is so great about using binary!
Alternatively we could use HEX digits, DEC digits or even OCT digits - you won't save any program memory space, but some people prefer to use these number systems rather than BIN (binary). As a side project - why don't you have a go at making this LED SCANNER do the same job by using decimal digits instead of binary, or maybe even hexadecimal? It's quite easy, you just need to change the letter infront of the digits and then change the binary to the equivalent number for your chosen number system.
• h is for hexadecimal
• d is for decimal
• o is for octal
• b is for binary
For example, if we were to send the binary number 00000001 to PORTB it would be exactly the same as sending HEX 01, DEC 001 or OCT 001. They are all the same number. Or if we sent the binary number 00010110 it would be the same as sending HEX 16, DEC 022 or OCT 026. I guess you could liken it to a nick name. Your name might be ANDREW and you might have the nickname ANDY. So it doesn’t matter if someone said ANDREW or ANDY - they are still referring to you.
So you should be able to see in this example, that we first clear PORTB so that all LED's are off when we first turn the circuit on. Then we send eight bits of data to PORTB which turns the right most LED ON - we then call the delay to hold PORTB in this present state. Then the very next instruction sends a brand new 8-bits to PORTB whereas the in previous sourcecode example, we were just concerned with one bit at a time. It still achieves the same result, but is a good learning tool to show you how we are able to use different instructions to achieve the same goal.
Now, just before we get to the nice an efficient version which will use loops, we will have a look at a couple of new instructions - these being rlf and rrf
You can download the third piece of sourcode here