'------------------------------------------ 'lalarm.bs2 ' 'This high-level program uses the light sensor 'to activate an alarm when the light gets bright. 'You'll have to adjust the trip point to work 'for your sensor. lightl var word 'Light Level 'If dark then do nothing main: gosub getll 'Get light level if lightl < 100 then alarm 'Trip point goto main 'Loop forever. alarm: freqout 9,150,2000 'Alarm sound pause 100 low 10 'Red LED on. freqout 9,400,900 'Alarm sound pause 100 high 10 'Red LED off. goto main '------------------------------------------ 'getll 'Reads the light level and sets variable lightl getll: high 4 'Discharge cap pause 1 'Short delay rctime 4,1,lightl 'Capture light level return 'Done