'
***************************
'Written in PIC16 IDE BASIC
'(C) Oshonsoft (
www.oshonsoft.com)
'***************************
'Set ports to digital (A/D converters off etc)
AllDigital
'Initialise port states
'Port A is all input
TRISA = ffh
'Port B is all output
TRISB = 00h
'Ensure all relays are off
RB0 = 0
RB1 = 0
RB2 = 0
RB3 = 0
'Test if the trigger input is active and wait if it isn't
monitor:
While RA0 = 0
'Do not a lot!
Wend
'At this point, the alarm must have been triggered
'Firstly, check whether GSM phone is on by pressing red button
turnon:
RB2 = 1
WaitMs 200
RB2 = 0
'and then seeing if the backlight is on
If RA1 = 0 Then
'Turn the phone on by holding the power button in for 2 seconds
RB3 = 1
WaitMs 2000
RB3 = 0
'Allow enough time (20 seconds) for the phone to come on
WaitMs 20000
Endif
'Now check the backlight again, if it still isn't on, try again
If RA1 = 0 Then Goto turnon
'At this point, the phone is on and waiting.
'So hold our first speed-dial button in for 1.5 seconds
RB0 = 1
WaitMs 1500
RB0 = 0
'Wait 30 seconds to allow dialing out etc.
WaitMs 30000
'Then hang up
RB2 = 1
WaitMs 1000
RB2 = 0
'Allow the phone to settle
WaitMs 2000
'then hold our second speed-dial button in for 1.5 seconds
RB1 = 1
WaitMs 1500
RB1 = 0
'Wait 30 seconds to allow dialing out etc.
WaitMs 30000
'Then hang up
RB2 = 1
WaitMs 1000
RB2 = 0
'And after all that, go back and do it ALL again.
Goto monitor