@ device hs_osc
define osc 20
DEFINE CHAR_PACING 10
include "modedefs.bas"
'-------------------------------------------------------------------------------
i var byte
s var byte[90]
n var byte[90]
'-------------------------------------------------------------------------------
trisb=0
portb=0
trisc=%10000010
portc=0
trisa=0
porta=0
'-------------------------------------------------------------------------------
define lcd_dreg portb
define lcd_dbit 4
define lcd_rsreg portb
define lcd_rsbit 1
define lcd_ereg portb
define lcd_ebit 0
define lcd_bits 4
define lcd_lines 2
lcdout $fe,$01
'-------------------------------------------------------------------------------
cr con 13
cz con 26
cot con 34
space con 32
comma con 44
'################################################# ##############################
clear
high portb.3 'Switching ON"
lcdout $fe,$01
lcdout $fe,128,"Power-UP....",#i
pause 1200
lcdout $fe,128,"Power released"
low portb.3
pause 10000
'************************************************* *******************************
ini:
clear
lcdout $fe,$01
for i=0 to 4
serout portc.6,T9600,["AT",cr]
pause 1000
lcdout $fe,128,"Initialize ",#i
next i
serout portc.6,T9600,["AT+CMGF=1",cr]
pause 1000
serout portc.6,T9600,["AT+CMGDA=",cot,"DEL",space,"ALL",cot,CR] '* DELETE all message
pause 1500
lcdout $fe,1
serout portc.6,T9600,["AT+CMTE?",cr]
serin portc.7,T9600,1000,ini,["+CMTE:"],n(24)
for i=25 to 29
serin portc.7,T9600,1000,ini,n(i)
next i
LCDout $fe,192,"Temp=",n(27),n(28),223,"C"
PAUSE 1000
start:
if portc.1=0 then
for i=30 to 42
serin portc.7,T9600,1000,start,n(i)
next i
if ( n(33)="C" and n(34)="M" and n(35)="T" and n(36)="I") then
lcdout $fe,1
lcdout $fe,128,"Reading"
pause 1000
serout portc.6,T9600,["AT+CMGR=",n(42),cr]
serin portc.7, T9600,5000,w2,["+CMGR:"],s(0)
for i=1 to 84
serin portc.7, T9600,1000,w2,s(i)
next i
endif
endif
if (s(59)="S") then
high portc.3
s(59)=0
endif
if(s(59)="T" and s(60)="a") then
low portc.3
s(59)=0
s(60)=0
endif
lcdout $fe,1
lcdout $fe,128,s(59),"s59",#s(59)
lcdout $fe,192,s(59),s(60)," 59-60-END" ;for myself understanding and tracing on datas on LCD
serout portc.6,T9600,["AT+CMGD=",n(42),comma,4,cr]
pause 1000
goto start
'************************************************* *******************************
'************************************************* *********************************
w2:
pause 5000
serout portc.6,T9600,["AT+CMGR=",n(42),cr]
serin portc.7, T9600,5000,ini,["+CMS ERROR:"],s(87),s(88),s(89)
pause 5000
lcdout $fe,01
lcdout $fe,128,"SMS receiving"
lcdout $fe,192,"Error=",s(87),s(88),s(89)
pause 2000
goto start
'************************************************* *************************************************
END
Bookmarks