'{$STAMP BS2}

'DIR is a way to set all pins with one command using binary numbers

'we know a number is binary because the % sign preceeds it in PBasic

'LEDS is used as a variable to turn leds on and offbased on shifting a high signal up and down the pins


LEDs VAR OUTL 'LEDs on Pins 0-7

'constants
DelayTime CON 100 'delay time in milliseconds

'initialization

Initialize:
DIRL = %11111111 'make all pins output
LEDs = %00000001 'start with one LED on (pin 0)

'Program code

Go_Forward:
PAUSE DelayTime
LEDs = LEDS << 1
IF (LEDs = %10000000) THEN Go_Reverse
GOTO Go_Forward

Go_Reverse:
PAUSE DelayTime
LEDS = LEDs >> 1
IF (LEDs = %00000001) THEN Go_Forward
GOTO Go_Reverse

END