program syntax
Archiver
Posts: 46,084
i'm writing a program for the BS2 for a security system. I will have external
circuits and sensors attached but testing the code, i'm hardcoding various
combinations....
alarms var nibble
motion var alarms.bit0
noise var alarms.bit1
glass var alarms.bit2
door var alarms.bit3
alarms.bit0 con 1
alarms.bit1 con 2
alarms.bit2 con 3
alarms.bit3 con 4
buzz con 7
light con 8
light1 con 9
alarms = [noparse][[/noparse]1001]
GOSUB check
alarms = [noparse][[/noparse]0010]
GOSUB check
alarms = [noparse][[/noparse]1000]
GOSUB check
alarms = [noparse][[/noparse]0100]
GOSUB check
end
check:
alarms =INA
Branch INA,[noparse][[/noparse]check,,message,message,alarm,message,alarm,alarm,alarm,light]
RETURN
LED:
low light
pause 250
high light
RETURN
Message:
FOR counter 0 to 3
GOSUB blink
NEXT
blink:
low light1
pause 50
high light1
pause 50
RETURN
Alarm:
low buzz
pause 50
high buzz
RETURN
circuits and sensors attached but testing the code, i'm hardcoding various
combinations....
alarms var nibble
motion var alarms.bit0
noise var alarms.bit1
glass var alarms.bit2
door var alarms.bit3
alarms.bit0 con 1
alarms.bit1 con 2
alarms.bit2 con 3
alarms.bit3 con 4
buzz con 7
light con 8
light1 con 9
alarms = [noparse][[/noparse]1001]
GOSUB check
alarms = [noparse][[/noparse]0010]
GOSUB check
alarms = [noparse][[/noparse]1000]
GOSUB check
alarms = [noparse][[/noparse]0100]
GOSUB check
end
check:
alarms =INA
Branch INA,[noparse][[/noparse]check,,message,message,alarm,message,alarm,alarm,alarm,light]
RETURN
LED:
low light
pause 250
high light
RETURN
Message:
FOR counter 0 to 3
GOSUB blink
NEXT
blink:
low light1
pause 50
high light1
pause 50
RETURN
Alarm:
low buzz
pause 50
high buzz
RETURN
Comments
>i'm writing a program for the BS2 for a security system. I will have external
>circuits and sensors attached but testing the code, i'm hardcoding various
>combinations....
>
>
>alarms var nibble
>motion var alarms.bit0
>noise var alarms.bit1
>glass var alarms.bit2
>door var alarms.bit3
>
>alarms.bit0 con 1
>alarms.bit1 con 2
>alarms.bit2 con 3
>alarms.bit3 con 4
>buzz con 7
>light con 8
>light1 con 9
>' Corrected Simplified
>alarms = [noparse][[/noparse]1001] ' %1001 or 9
>GOSUB check
>
>alarms = [noparse][[/noparse]0010] ' %0010 or 2
>GOSUB check
>
>alarms = [noparse][[/noparse]1000] ' %1000 or 8
>GOSUB check
>
>alarms = [noparse][[/noparse]0100] ETC.
>GOSUB check
>
>end
<clipped to save space>
Hi -
See if that helps with the progress. Looking GOOD !
Regards,
Bruce Bates