' {$STAMP BS2} ' {$PBASIC 2.5} time VAR Word 'declare time for sensor x VAR Byte 'declare x for counting what station its at c VAR Byte 'declare c for bypass sensor rotate motor number of times HIGH 1 'turn on sensors =====================================Motor loop====================================== go: DO HIGH 0 'check photoresistor for light PAUSE 100 RCTIME 0, 1, time HIGH 2 'motor turn PAUSE 3 LOW 2 PAUSE 3 HIGH 4 PAUSE 3 LOW 4 PAUSE 3 HIGH 3 PAUSE 3 LOW 3 PAUSE 3 HIGH 5 PAUSE 3 LOW 5 PAUSE 3 LOOP UNTIL (time = < 50) 'turn motor until light is seen ===================================rules============================================= IF time = > 50 THEN 'if no light is seen then continue with motor loop GOSUB go ENDIF IF time = < 50 THEN 'if light is seen then stop GOSUB stp ENDIF ===============================stop routine========================================= stp: x = x + 1 'add one to station counting loop IF x = 1 THEN DEBUG "Filling Tank To 3000 Gallons of Waste" ,CR ENDIF IF x = 2 THEN DEBUG "Heating Tank To 500 Degrees" , CR ENDIF IF x = 3 THEN DEBUG "Radiation Screening" ,CR ENDIF PAUSE 2000 IF x = 4 THEN DEBUG "Cooling Down Tank" ,CR HIGH 6 PAUSE 6000 LOW 6 ENDIF IF x = 5 THEN DEBUG "Process Complete" ,CR HIGH 8 'sound alarm PAUSE 100 LOW 8 PAUSE 50 HIGH 8 PAUSE 1000 LOW 8 'turn off buzzer LOW 1 'turn off sensors END 'end program ENDIF GOSUB light ====================================light routine======================= light: LOW 1 'turn off sensors DO 'rotate motor passed the sensor HIGH 2 PAUSE 10 LOW 2 PAUSE 10 HIGH 4 PAUSE 10 LOW 4 PAUSE 10 HIGH 3 PAUSE 10 LOW 3 PAUSE 10 HIGH 5 PAUSE 10 LOW 5 PAUSE 10 c = c + 1 'add one to motor pass count LOOP UNTIL (c = 9) 'loop 9 times c = 0 'reset count HIGH 1 'turn on sensors GOSUB go 'start back over