unsigned char* MSG1 = "AT";
unsigned char* MSG2 = "at+CMGF=1";
unsigned char* MSG3 = "AT+CPMS=\"ME\"\n";
unsigned char* MSG4 = "AT+CNMI=2,1,0,0,0";
unsigned char* MSG5 = "AT+CMGR=1";
unsigned char* MSG6 = "AT+CMGD=1";
unsigned char output[70];
int i=0,flag=0;
void main() {
int ctr,x=0;
TRISB=0x02;
TRISD=0;
PORTB=0;
PORTD=0;
UART1_Init(9600);
for(ctr=0;ctr<3;ctr++)
{
PORTB=0x01;
Delay_ms(500);
PORTB=0;
Delay_ms(500);
}
//UART1_Write_Text(MSG1); //at
//Delay_ms(1000);
//UART1_Write(0X0D); // ENTER
//Delay_ms(1000);
UART1_Write_Text(MSG2); //cmgf=1
Delay_ms(1000);
UART1_Write(0X0D); // ENTER
Delay_ms(1000);
UART1_Write_Text(MSG3); //cpms
Delay_ms(1000);
UART1_Write(0X0D); // ENTER
Delay_ms(1000);
a:
UART1_Write_Text(MSG5); //cmgr
Delay_ms(1000);
UART1_Write(0X0D); // ENTER
Delay_ms(3000);
UART1_Write_Text(MSG5); //cmgr
Delay_ms(1000);
UART1_Write(0X0D); // ENTER
do{
UART1_Read_Text(output, "OK", 65); reads text until 'OK' is
found
PORTD=output[x];
UART1_Write_Text(output); // sends back text
}
x++ ;
} while(x<2);
Delay_ms(1000);
Delay_ms(3000);
for(ctr=0;ctr<3;ctr++)
{
PORTB=0x01;
Delay_ms(500);
PORTB=0;
Delay_ms(500);
}
x=0;
goto a;
}
void sms_read();
void sms_send();
char output[70];
void main() {
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
sms_read(); //to read the sms in location 1
delay_ms(500);
sms_send(); //send an sms
}
void sms_read()
{
unsigned char i;
UART1_Write_Text("AT\n\r");
delay_ms(500);
UART1_Write_Text("AT+CMGF=1\n\r");
delay_ms(500);
UART1_Write_Text("AT+CMGR=1\n\r");
delay_ms(500);
UART1_Write_Text("AT+CMGR=1\n\r");
delay_ms(500);
while (UART1_Data_Ready() == 0) ;
for(i=0;i<=65;i++)
{
output[i]=UART1_Read();
}
delay_ms(500);
}
void sms_send()
{
int i;
/*UART1_Write_Text("AT\n\r");
delay_ms(500);
UART1_Write_Text("AT+CMGF=1\n\r");
delay_ms(500); */
UART1_Write_Text("AT+CMGS=");
UART1_Write(0x22);
UART1_Write_Text("+919444721638");
UART1_Write(0x22);
UART1_Write_Text("\n\r");
delay_ms(500);
UART1_Write_Text(output);
UART1_Write(26);// send ctrl + Z
}
Yesmsmomar said:1-Can i use 8 Bit micro controller to send through UART ?
USART is a UART that can send either Synchronous or Asynchronous data - look at the datasheetmsmomar said:2- Can i use mc as PIC18f44500 , but id doesn't contain UART , it contain USART & MSSP & USB ???
First, you need a controller that has a USB Host or OTG interface (available only in PIC24 & PIC32 families). Secondly, it is much more difficult to program USB than serial.msmomar said:3-Does transmitting data through USB is complicated ?( i'm not professional in mc )
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?