Code:
PushButton var PORTB.0 ' Setup the name PushButton to mean PortB input 0
Main:
IF PushButton = 0 THEN SMS 'If button is pressed then run the SMS routine below
goto main ' however if the button is not pushed then just go back to the Main
' routine to wait for the button to be pressed
SMS: ' this is the SMS commands routine in order to send an SMS
SEROUT PORTB.1,6,["AT" ,13,10] ' send AT to phone followed by a CR and line feed
SERIN PORTB.2,6,["OK"] ' now wait until OK is received
SEROUT PORTB.1,6,["AT+CMGF=1" ,13,10]
SERIN PORTB.2,6,["OK"]
SEROUT PORTB.1,6,["AT+CMGS=+256782277658"]
SEROUT PORTB.1,6,[13,10]
SERIN PORTB.2,6,[">"]
SEROUT PORTB.1,6,["BUTTON HAS BEEN PRESSED!"]
SEROUT PORTB.1,6,[26] ' this is ASCII for Ctrl+Z of which completes SMS sending
SERIN PORTB.2,6,["+CMG"] ' then PIC should receive +CMG from modem
SEROUT PORTB.1,6,[10] 'ascii code for a line feed
'---------- second number------------
SEROUT PORTB.1,6,["AT+CMGS=+000222333666444"]
SEROUT PORTB.1,6,[13,10]
SERIN PORTB.2,6,[">"]
SEROUT PORTB.1,6,["BUTTON HAS BEEN PRESSED!"]
SEROUT PORTB.1,6,[26] ' this is ASCII for Ctrl+Z of which completes SMS sending
SERIN PORTB.2,6,["+CMG"] ' then PIC should receive +CMG from modem
SEROUT PORTB.1,6,[10] 'ascii code for a line feed
end
Ioannis
Bookmarks