dijam014
Newbie level 4
Hi everyone, I need help about my project on the interfacing part of the GSM to the microcontroller(pic16f877), I need to control some switching devices(outlets using relays) to turn them on and off using text message(sms) via GSM. I am using mikrobasic as my programming language, and as a temporary replacement for the GSM I am using the mikrobasic usart terminal for testing some codes. Currently I am trying to figure out how to use the usart_data_ready command and I tried the code below. Can anyone kindly share with me some codes regarding this project and any advice or clarifications with the code below. Thanks in advance for the help
program readstring
dim txt, delim as char[20]
trisA= %000000
main:
porta = %000000
USART_init(9600)
delim = "ON"
while true
if Usart_Data_Ready = 1 then
Usart_Read_Text(txt, delim) ' read text until "OK" is received
Usart_Write_Text(txt) ' write back what has been read
delay_ms(400)
porta = %011011
else
'if not equal to ON then reply "invalidkeyword" the GSM will send a 'message invalid
end if
wend
end.
program readstring
dim txt, delim as char[20]
trisA= %000000
main:
porta = %000000
USART_init(9600)
delim = "ON"
while true
if Usart_Data_Ready = 1 then
Usart_Read_Text(txt, delim) ' read text until "OK" is received
Usart_Write_Text(txt) ' write back what has been read
delay_ms(400)
porta = %011011
else
'if not equal to ON then reply "invalidkeyword" the GSM will send a 'message invalid
end if
wend
end.