@ device PIC16F72 , xt_osc, wdt_off, pwrt_on, protect_oN
Include "MODEDEFS.BAS" ' Include Shiftin/out modes
DEFINE DEBUG_REG PORTC
DEFINE DEBUGIN_REG PORTC
DEFINE DEBUGIN_BIT 7
DEFINE DEBUG_BIT 6
DEFINE DEBUG_MODE 0 ' 1 = Inverted (w/o max) , 0 = true (with max)
DEFINE DEBUGIN_MODE 0
DEFINE DEBUG_BAUD 9600
'-----------------------------------------------------------------
' HARDWARE DEFINES
'-----------------------------------------------------------------
' Define LCD pins
Define Lcd_dreg Porta
Define Lcd_dbit 0
Define Lcd_rsreg Porta
Define Lcd_rsbit 4
Define Lcd_ereg Porta
Define Lcd_ebit 5
'-----------------------------------------------------------------
Define Osc 4 ' We're using a 4 MHz oscillator
'-----------------------------------------------------------------
Adcon1 = 7 ' Set PORTA DIGITAL
OPTION_REG.7 = 0 ' DISABLE INTERNAL PULLUPS
Trisa = %00000000 ' SETS ALL PORTA PINS TO OUTPUT
Trisb = %00000000 ' ALL OUTPUT
Trisc = %00001011 ' 6 Pins - LCD and 2 Pins RF Module
'-----------------------------------------------------------------
RELAY1 VAR PORTB.0 ' RELAY 1
RELAY2 VAR PORTB.1 ' RELAY 2
RELAY3 VAR PORTB.2 ' RELAY 3
RELAY4 VAR PORTB.3 ' RELAY 4
RELAY5 VAR PORTB.4 ' RELAY 5
RELAY6 VAR PORTB.5 ' RELAY 6
RELAY7 VAR PORTB.6 ' RELAY 7
RELAY8 VAR PORTB.7 ' RELAY 8
LED VAR PORTC.4 ' LED (SINK)
RELAY VAR BYTE ' RELAY NUMBER
MYDATA VAR BYTE ' GENERAL PURPOSE DATA VARIABLE
INDEX VAR BYTE ' SMS INDEX NUMBER
I VAR BYTE ' GENERAL VARIABLE
Pause 500 ' Wait .5 second
'-----------------------------------------------------------------
B2400 Con 16780 ' Inverted 2400 baud for SERIN2
HIGH LED
PORTB = 0 ' TURN OFF ALL RELAYS
Lcdout $fe, 1, "SMS CONTROL" ' Send to LCD
Lcdout $fe, $C0, "SMS TEST C5" ' Second Line
PAUSE 2000
' GOSUB OLD
LOOP:
Lcdout $fe, 1, "WAITING 4 SMS" ' Send to LCD
DEBUGIN [WAIT("+CMTI:"), SKIP 7 , DEC INDEX]
Lcdout $fe, $C0, "SMS RX: " , DEC INDEX ' Second Line
PAUSE 5000
Lcdout $fe, 1, "READ MSG " ' Send to LCD
DEBUG "AT+CMGR=", DEC INDEX, 13
'DEBUGIN [WAIT("+CMGR:"), SKIP 51 , DEC MYDATA]
DEBUGIN [WAIT("+CMGR:"), SKIP 53 , DEC MYDATA]
Lcdout $fe, 1, "MYDATA: " , DEC MYDATA ' Send to LCD
PAUSE 3000
SELECT CASE MYDATA
CASE 20
Lcdout $fe, 1, "RELAY 2"
Lcdout $fe, $C0, "ON"
CASE 21
Lcdout $fe, 1, "RELAY 2"
Lcdout $fe, $C0, "OFF"
CASE 10
Lcdout $fe, 1, "RELAY 1"
Lcdout $fe, $C0, "ON"
CASE 11
Lcdout $fe, 1, "RELAY 1"
Lcdout $fe, $C0, "OFF"
CASE 30
Lcdout $fe, 1, "RELAY 3"
Lcdout $fe, $C0, "ON"
CASE 31
Lcdout $fe, 1, "RELAY 3"
Lcdout $fe, $C0, "OFF"
CASE 40
Lcdout $fe, 1, "RELAY 4"
Lcdout $fe, $C0, "ON"
CASE 41
Lcdout $fe, 1, "RELAY 4"
Lcdout $fe, $C0, "OFF"
END SELECT
PAUSE 3000
Lcdout $fe, 1, "DELETE SMS MSG"
Lcdout $fe, $C0, "#:" , DEC INDEX
DEBUG "AT+CMGD=", DEC INDEX, 13
PAUSE 3000
GOTO LOOP
END