Source Code

The following code is the program that the micro-controller uses to function as the brain of the alarm system.
Click and hold shift here for the .bs2 file.
 

X VAR BYTE   'counter variable
X1 VAR BYTE   'counter variable
ENABLE VAR BYTE
Y VAR BIT   'boolean variable
M1 VAR BIT
M2 VAR BIT

INPUT 5    'enable input
INPUT 6    'motion sensor 1
INPUT 7    'motion sensor 2
OUTPUT 8   'alarm output
OUTPUT 9   'alarm armed output

MAIN:
LOW 8
BUTTON 5,1,255,255,enable,1,ARMED 'if enable, arm system
GOTO MAIN

ARMED:
PAUSE 60000   'wait for 1 minute to exit house
Y=(IN6&IN7)   'motion
IF Y=0 THEN ALARM  'if motion, turn on siren
IF IN5 = 0 THEN MAIN
GOTO ARMED

ALARM:
PAUSE 15000   'wait for 10 sec for accidental trip
HIGH 8    'turn on siren
FOR X1 = 1 TO 12000  'pause for .1 sec.  check to see
PAUSE 100   'if still enabled.  if not enabled, turn
IF IN5 = 0 THEN MAIN  'alarm off, else wait 10sec.
NEXT
LOW 8    'turn siren off
GOTO ARMED   'go back and wait for motion
 

Back to Table of Contents
Go to Next Section