#include <reg51.h>
#include <stdio.h>
#define dataport P1;
sbit irout=P2^1;
sbit rs=P2^2;
sbit rw=P2^3;
sbit e=P2^4;
void serial_init(void);
void delay(int);
void lcdinit();
void lcdcmd(unsigned char);
void lcddata(unsigned char);
void convert(unsigned char *);
void serial_init(void)
{
SCON = 0x50;
TMOD = 0x20;
TH1 = 0xFD;
TR1 = 1;
TI = 1;
}
void serial(void) interrupt 4
{
unsigned int y[25];
if(RI==1)
{
y[25]=SBUF;
RI=0;
lcdinit();
convert(y[25]);
}
}
void lcdinit()
{
lcdcmd(0x38); //2 Line, 5X7 Matrix
lcdcmd(0x0c); //Display On, Cursor Blink
delay(1);
lcdcmd(0x01); // Clear Screen
delay(1);
lcdcmd(0x81); // Setting cursor to first position of first line
delay(1);
}
void convert(unsigned char *strs)
{
unsigned char m;
while(strs[m]!='\0')
{
lcddata(strs[m]);
m++;
}
}
void lcddata(unsigned char dat)
{
dataport = dat;
rs=1;
rw=0;
e=1;
delay(1);
e=0;
return;
}
void lcdcmd(unsigned char dat)
{
dataport = dat;
rs=0;
rw=0;
e=1;
delay(1) ;
e=0;
return;
}
void delay(int n)
{
int i,j;
for(i=0;i<n;i++)
for(j=0;j<1000;j++);
}
void main(void)
{
IE=0x90;
irout=1;
irout=0;
while(1)
{
if(irout==1)
{
delay(200);
serial_init();
printf("AT+CMGF=1%c",13);
delay(200);
printf("AT+CMGS=\"9747358520\"%c",13);
delay(200);
printf("Hi :-) GSM Modem Test");
delay(20);
printf("%c",0x1A);
delay(200);
while(irout==1);
}
}}