Scanner pattern PICAXE code

'# knightrider.bas  Rob stave
'# Produces an led sequence that goes
'# back and forth
'# Intended for 4094
'# www.robthefiddler.com

symbol INPUT_PIN = 4
symbol DATA_PIN = 1
symbol CLOCK_PIN = 0
symbol STROBE_PIN = 2
symbol val = b0
symbol direction = b1
symbol up = 0
symbol down = 1

begin:
low DATA_PIN
low CLOCK_PIN
low STROBE_PIN

val = 1;
direction = 0

main:

'#  val is b0 so just read the bits out
'#  and pulse the clock
    pin1 = bit7
    pulsout CLOCK_PIN, 100
    pin1 = bit6
    pulsout CLOCK_PIN, 100
    pin1 = bit5
    pulsout CLOCK_PIN, 100
    pin1 = bit4
    pulsout CLOCK_PIN, 100
    pin1 = bit3
    pulsout CLOCK_PIN, 100
    pin1 = bit2
    pulsout CLOCK_PIN, 100
    pin1 = bit1
    pulsout CLOCK_PIN, 100
    pin1 = bit0
    pulsout CLOCK_PIN, 100	

'#  pulse the stobe
    pulsout STROBE_PIN, 100

'#  determine if the direction changed
    IF  direction = up  AND val = %10000000 THEN
       direction = down
       goto shiftit
    END IF

    IF direction = down AND val = %00000001 THEN

       direction = up
    END IF

shiftit:

    IF direction = up THEN
       val = val * 2
    ELSE
       val = val /2
    ENDIF

    readadc INPUT_PIN, w3
'#  wait a little bit
    w3 = w3 * 2
    pause w3		

    goto main