[DIY108]

Do it yourself !


Zedomax Alarm System II

Make an alarm system in 3 minutes! (Part II)

Add a motion sensor!

Here's a video of Zedomax Alarm System II in Action:

 

 

Parts List:

1 RadioShack Motion-sensing Door Chime/Alarm                   $27

Other parts from Zedomax Alarm System Part I

Estimated Time to Assemble:   3 minutes

Estimated Time to Program:    10 minutes (or none if you use my source code)

 

The other day I was walking through RadioShack and found this neat little Motion-sensing Door Chime/Alarm.  

Since I already had an alarm system, I decided I could simply add a motion-sensor to my existing alarm system.

 

 

Connections

1) First disassemble the motion-sensor like shown in above picture.

2) Now disconnect the speaker wires, we don't need the speaker on the motion sensor since we already have one on our alarm system.

 

3) Solder 2 wires to the speaker wires.  Make sure to mark one of the wires as ground for later.  I used a black tape to mark it.

4) When you measure the speaker outputs, you should get around 8V DC, we will need this information in order to not burn up our CB280 module.

5) You can take the wires outside of the casing through the battery connectors.

 

6) Assemble your motion-sensor now like shown above.

7) Now you have a motion sensor w/ 2 wires you can use to sense motion!  

8) Connect the the Positive wire of the motion sensor to the middle of a 3804 TR.  

Connect the GND of motion sensor to GND of the study board.

Now you can connect 5V of the study board to the right side of the 3904 TR and the P21 of the study board to the left side of the 3904 TR as shown in the above picture.

Connect a LED Output to P21 to check that motion sensor is working and the CUBLOC module will receive correct digital signals.

Now check that your motion sensor is working by turning the motion sensor to "Chime" and try flickering your hands in front of it.  

The LED on the motion sensor and the study board should go off together in harmony.

Now simply unzip and download this program using CublocStudio:

HomeAutomation002.zip

You should get a nice Motion line added to your existing alarm system.

Try turning On your alarm system, the password is 1234.

Now make some movements on the motion sensor to set it off.

The alarm system will go off and the only way to turn it off is by entering your password again.

Press the CNCL button if you mess up your password.

Program Source...

(Bold for added code)

Const Device = CB280

#define MyPass 1234

Set Pad 0,1,10

 

 

Const Byte KEY_TABLE=(0,0,14,16,0,15,0,0,0,0,13,9,8,7,0,0,0,0,12,6,5,4,0,0,0,0,11,3,2,1)

'Key table if Keypad inserted backwards to the Keypad Controller

'Const Byte KEY_TABLE=(0,0,1,4,7,10,0,0,0,0,2,5,8,11,0,0,0,0,3,6,9,12,0,0,0,0,13,14,15,16)

 

Dim X As Byte

'Status of Alarm

Dim AlarmON As Byte

Dim AlarmStayON As Byte

 

'Status of Door

Dim Door As Byte

 

'Status of Motion Sensor

Dim Motion As Byte

 

Dim Password As Long

 

Door=0

Motion=0

 

Password=0

 

AlarmON=0

AlarmStayON=0

Input 0

Input 1

Input 2

Input 3

 

 

'Set port P5 to output

Output 5

 

'Set Magnetic Switch to input

Input 20

On INT0 Gosub GETINT

Set int0 2

 

Input 21

On INT1 Gosub GETINT_M

Set int1 2

 

 

On Pad Gosub PAD_RTN

 

Set Ladder Off

 

Set Display 2,0,0,128

Cls

Delay 100

Csroff

Locate 0,0

Print "Zedomax Alarm System"

 

'Add motion sensor LCD commands

Locate 0,1

Print "Motion: "

If In(21)=1 Then

    Print "movement"

Else

    Print "none"

End If

 

 

 

Locate 0,2

Print "Door is: "

If In(20)=1 Then

    Print "open"

Else

    Print "closed"

End If

 

If AlarmON=1 Then

    Locate 0,3

    Print "Alarm Status is ON"

Else

    Locate 0,3

    Print "Alarm Status is OFF"

End If

 

 

Do

    If (AlarmON=1 And Door=1) Or (AlarmON=1 And Motion=1) Then

        AlarmStayON=1

    End If

 

    If AlarmStayON=1 Then

        Alarm

    End If

Loop

 

GETINT:

 

    Door=In(20)

    Debug "Door: ",Dec Door,Cr

    Alarm

    

    If Door=0 Then

        Locate 9,2

        Print "closed  "

        Debug "door closed",Cr

    Else

        Locate 9,2

        Print "open   "

        Debug "door open",Cr

    End If  

    

    

    

    Delay 500

Return

 

GETINT_M:

    

    Motion=In(21)

    Debug "Motion: ",Dec Motion,Cr

 

 

    'Add motion sensor LCD commands

    If Motion=0 Then

        Locate 8,1

        Print "none    "

    Else

        Locate 8,1

        Print "movement    "

    End If

    

    Delay 200

Return

 

 

 

PAD_RTN:

    Peep

    X=Getpad(1)

    If X>29 Then Return

 

    X=KEY_TABLE(X)

    Debug "Key Pressed: ", Dec X,Cr

    

    If X < 10 Then

        Password=Password*10+X

        If Password > 9999 Then Password=X

        Debug "Password: ", Dec Password,Cr

 

        If Password = MyPass Then

            AlarmON=AlarmON Xor 1

            If AlarmON=1 Then

                Locate 0,3

                Print "Alarm Status is ON "

            Else

                Locate 0,3

                Print "Alarm Status is OFF"

                AlarmStayON=0

            End If

 

            

        End If          

 

    'If ENTR pressed

    Elseif X=11 Then

    'If CNCL pressed

    Elseif X=15 Then

        Password=0

 

    End If

    

Return

 

 

End

 

Sub Alarm()

    Out 5,1

    Delay 100

    Out 5,0

    Delay 100

End Sub

 

Sub Peep()

    Out 5,1

    Delay 5

    Out 5,0

    Delay 5

End Sub