Microcontroller › AVR › By using GSM SIM 300M and Atmega8 , How to write coding for sending SMS to 3 Persons when any one the port pin gets high …? › Sorry for the delayed
Sorry for the delayed response. I hope your init() function is setting things properly. Now try exactly the following code with the hyperterminal and tell me whether it displays something on the terminal window.
#include<at89x52.h>
#define key P2^0
void delay(int time);
void init();
void SMSString(unsigned char* text);
void tx0(unsigned char x);
void main()
{
P2=0x00;
init();
tx0 (‘h’);
tx0 (‘a’);
tx0 (‘i’);
SMSString(“ATr”);
delay(1000);
delay(1000);
SMSString(“AT+CMGF=1r”);
delay(1000);
delay(1000);
SMSString(“AT+CMGS=”8080808080″r”);
delay(1000);
SMSString(“This is a test messag “);
delay(1000);
tx0(0x1A);
delay(1000);
delay(1000);
delay(1000);
while ( 1 )
{
;
}
}
void delay(int time) //This function produces a delay in msec.
{
int i,j;
for(i=0;i<time;i++)
for(j=0;j<1000;j++);
}
void init()
{
TMOD=0x20;
SCON=0x50;
TL1=0XFD; //9600 @ 11.0592
TH1=0xFD;
TR1=1;
}
void SMSString(unsigned char* text) //function to send SMS using GSM modem
{
unsigned char count = 0;
while (text[count])
{
tx0(text[count++]);
}
}
void tx0(unsigned char x) //send data to serial port 0
{
EA=0;
SBUF=x;
while(TI==0);
TI=0;
EA=1;
}