'Light2.bas: '* * 'an example, traveling light goes off from the first on to the last one** '* * 'UP = P3.2, DOWN = P3.3, up/down keys** Dim Lights As Byte , Up As Bit , Down As Bit Lights = 1 'set initial value of the Lights variable P1 = Lights 'Lights are on P1 Do 'start of the DO-LOOP loop Up = P3.2 'Up key is on the P3.2 port Down = P3.3 'Down key is on the P3.3 port If Up = 0 Then 'if Up = 0 rotate our lights Rotate Lights , Left 'left P1 = Lights 'send Lights to P1 Wait 1 'wait 1 second to slow things down so we can see them If Lights = 0 Then Wait 1 'wait 1 second Lights = 1 'set Lights variable value P1 = Lights 'set Lights to P1 Wait 1 'wait 1 second End If End If If Down = 0 Then 'similar procedure as for the Up key is also Rotate Lights , Right P1 = Lights 'for Down Wait 1 If Lights = 0 Then ' Wait 1 an example of false order Lights = 128 P1 = Lights Wait 1 'this wait 1 is at the right place End If End If Loop End 'end of program