Backpack alarm HELP
Brian B
Posts: 31
I am trying to create an alarm for my backpack but when I wrote the program and downloaded it it didn't work the way i thought. here is my code and key for what input is what. Please Help
Here is the key:
IN15 = lock/ backpack zipper
IN14 = disarm button
0 = green LED
5 = red LED
Explination:
my plan was to have an alarm go off when the zipper was opened without the disarm button being pushed
Here is the program:
' {$STAMP BS2}
' {$PBASIC 2.5}
'
Variables
counter VAR Word
disarm VAR Word
'
Main Program
DO
IF (IN14 = 0) THEN
disarm = 0
ELSE
IF (IN15 = 0) THEN
disarm = 1
ENDIF
ENDIF
IF (IN15 = 0) THEN
HIGH 0
ELSE
IF (disarm = 0) THEN
GOSUB open
ELSE
GOSUB flash
FREQOUT 4, 2000, 3000
ENDIF
ENDIF
LOOP
'
Subs
flash:
FOR counter = 1 TO 10
HIGH 0
PAUSE 1000
LOW 0
HIGH 5
PAUSE 1000
LOW 5
NEXT
RETURN
open:
FOR counter = 1 TO 10
HIGH 0
PAUSE 1000
LOW 0
NEXT
RETURN
Here is the key:
IN15 = lock/ backpack zipper
IN14 = disarm button
0 = green LED
5 = red LED
Explination:
my plan was to have an alarm go off when the zipper was opened without the disarm button being pushed
Here is the program:
' {$STAMP BS2}
' {$PBASIC 2.5}
'
Variables
counter VAR Word
disarm VAR Word
'
Main Program
DO
IF (IN14 = 0) THEN
disarm = 0
ELSE
IF (IN15 = 0) THEN
disarm = 1
ENDIF
ENDIF
IF (IN15 = 0) THEN
HIGH 0
ELSE
IF (disarm = 0) THEN
GOSUB open
ELSE
GOSUB flash
FREQOUT 4, 2000, 3000
ENDIF
ENDIF
LOOP
'
Subs
flash:
FOR counter = 1 TO 10
HIGH 0
PAUSE 1000
LOW 0
HIGH 5
PAUSE 1000
LOW 5
NEXT
RETURN
open:
FOR counter = 1 TO 10
HIGH 0
PAUSE 1000
LOW 0
NEXT
RETURN
Comments
The AND operator returns the logical AND of two values or expressions. Note that in the BASIC Stamp, a non-zero value is considered True (T), zero is considered False (F). The values/expressions are subject to the following logic: