Shop OBEX P1 Docs P2 Docs Learn Events
program syntax — Parallax Forums

program syntax

ArchiverArchiver Posts: 46,084
edited 2001-01-08 19:24 in General Discussion
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

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-01-08 19:24
    At 1/8/2001 Monday 01:48 PM -0500, sunset97 wrote:
    >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
Sign In or Register to comment.