#include <16F88.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc
#FUSES PUT //Power Up Timer
#FUSES PROTECT //Code protected from reads
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#use delay(int=4000000,RESTART_WDT)
#use rs232(uart1, baud=9600)//usart1 -->ajuste de XMIT y RCV para la USART 1
int i=0;
char Cadena[60]="";
char CadenaAux[60]="";
char ch;
int1 DatoPresente=0;
#int_rda
void rd_isr(void)//función de interrupción por recepción de datos USART
{
ch=getc();
Cadena[i]=ch;
CadenaAux[i]=ch;
i++;
if (ch==0x0d)DatoPresente=1;///si manda el enter termina el comando
}
void main()
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1 ( T1_INTERNAL | T1_DIV_BY_4 );
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);
set_tris_b(0x04); //portb como salida
set_tris_a(0x00); //porta como Entrada
enable_interrupts(int_rda);
enable_interrupts(GLOBAL); //activadas interrupciones
output_Low(PIN_B0);
while(1){
if(DatoPresente==1)
{
for (i=0;i<=60;++i)
{
ch=Cadena[i];
putc(ch);
Cadena[i]="";
}
i=0;
DatoPresente=0;
}
if((CadenaAux=="OK"+0x1A+0x0d))output_high(PIN_B0);
}
}Mas adelante tengo que reconocer otras cosas pero esta es la mas facil, me ayudan?
if((CadenaAux[0]=='O')&&(CadenaAux[1]=='K')&&(CadenaAux[2]=0x1A)&&(CadenaAux[3]=0x00D))output_high(PIN_B0);else output_loW(PIN_B0); funciona
void LeerSMS()
{
output_high(PIN_B1);
Comando="AT+CMGR="+CadenaAux[12]+CadenaAux[13]+CadenaAux[14];
printf(Comando);
CadenaAux[0]=' ';///para que no repita el bucle
}
AT+CMGL=1\r\n+CMGR: "REC READ","1234567890",,"12/07/30,00:12:05+32"
Mensaje_aca creo
OKLa ventaja de este metodo es que: AT+CMGL="REC UNREAD"+CMGL: 1,"REC READ","+85291234567",,"07/02/18,00:05:10+32"
Reading text messages is easy.
+CMGL: 2,"REC READ","+85291234567",,"07/02/18,00:07:22+32"
A simple demo of SMS text messaging.
+CMGL: 3,"REC READ","+85291234567",,"07/02/18,00:12:05+32"
Hello, welcome to our SMS tutorial.
OK