09-02-2016, 04:54 PM
Project code:
#include<LPC214x.H>
#include<LCD4LPC.H>
#include<UARTlpc.H>
# include<select0.h>
#include<string.h>
#include<gsm.h>
#include<gps.h>
# define motor1 (1 << 4)
# define motor2 (1 << 5)
# define motor3 (1 << 6)
# define motor4 (1 << 7)
# define sw (1 << 12)
# define buz (1 << 25)
unsigned int co,temp;
unsigned char flag,flag1,flag2,flaag,d[100],sms[20],lt[20],ln[20],j,loc,loc1,loc2,i,c_flag,t_flag,k;
unsigned int y;
void clear(void);
void clear1(void);
void eng(void);
void send(unsigned char *);
void con(unsigned int x) ;
void start(void);
void stop(void);
void interrupt_serial(void)__irq
{
unsigned char a,b;
if(((a=U1IIR) & 0x01)==0)
{
switch(a & 0x0E)
{
case 0x06:
{
b=U1LSR;
break;
}
case 0x04:
{
d[i]=U1RBR;
if(i==99)
{
U1IER=0x00;
flag1=1;
VICIntEnClr = 1<<7;
}
i++ ;
break;
}
case 0x02:
break;
case 0x0C:
break;
}
}
VICVectAddr=0;
}
int main()
{
lcdint();
IODIR1 |= buz;IODIR0 |= motor1; IODIR0 |= motor2 ;IODIR0 |= motor3 ;IODIR0 |= motor4; IODIR0 |= sw ;
delay(100);flag=1;flaag=1;y=1;j=0;loc1=loc=loc2=k=0,flag1=0,flag2=0;
c_flag=t_flag=0;
IOCLR1 = buz;IOCLR0 = motor1 ;IOCLR0 = motor2 ;IOCLR0 = motor3 ;IOCLR0 = motor4 ;IOSET0 = sw;
disp_loc(0x80,"PROJECT WELCOMES");disp_loc(0xc7,"YOU");delay(1000);
lcdcmd(0x01);
disp_loc(0x80,"RTA BASED POLLUTION");disp_loc(0xc0,"CHECKING SYSTEM");delay(1000);
lcdcmd(0x01);
delay(100);
//start();
PINSEL1=0x15400000;
PINSEL0 = 0x00000005;
lcdcmd(0x01);
disp_loc(0x80,"Intialising GSM..");
delay(1000);
uart0_init();
lcdcmd(0x01);
clear();clear1();loc1=loc=0;i=0;
GSM_SET();
delay(1000);
clear();
i=0;
while(1)
{
lab2:eng();
delay(1000);
lcdcmd(0x01);
disp_loc(0x80,"CO2:");
disp_loc(0x89,"TMP:");
AD0CR=0x002E0402;
AD0CR |= 0x01000000;
delay(50);
co=cal(1);
delay(50);
if(co>0x50)
{
c_flag=1;
lcdcmd(0x01);
disp_loc(0x80,"CO level high");
delay(500);lcdcmd(0x01);
IOSET1 = buz;delay(6000);delay(6000); IOCLR1 = buz;
}
disp_loc(0x80,"CO2:");
lcdcmd(0x85);
con(co);
delay(50);
AD0CR=0x002E0404;
AD0CR |= 0x01000000;
delay(100);
temp=cal(2);
delay(50);
if(temp>0x45)
{
t_flag=1;
lcdcmd(0x01);
disp_loc(0x80,"Temp is high");
delay(500);lcdcmd(0x01);
IOSET1 = buz;delay(6000);delay(6000); IOCLR1 = buz;
}
disp_loc(0x89,"TMP:");
lcdcmd(0x8D);
con(temp);
delay(50);
//c_flag=1;
if(c_flag==1)
{
c_flag=0;
gps_set();
delay(3000);
/* lcdcmd(0x01);
lcdcmd(0x80);
lcddata(k+0x30);
delay(100); */
lcdcmd(0x01);
disp_loc(0X80,"SMS SENDING...") ;
delay(1000);
send("+918008407294");
/*uart_tx_str("AT+CMGS=");uart_tx_char(0x22);uart_tx_str("+918008407294");uart_tx_char(0x22);delay(1000);
uart_tx_char(0x0D);*/
delay(1000);
uart_tx_str("CO level high ");
uart_tx_char(0x0d);
delay(100);uart_tx_str("LAT: ");
uart_tx_str(lt);uart_tx_char(0x0d);delay(100);
uart_tx_str("LANG: ");
uart_tx_str(ln);delay(1000); uart_tx_char(0x1A);delay(5000);
lcdcmd(0x01);
disp_loc(0X80,"SMS SENDED..");
IOSET1 = buz;
delay(6000);delay(6000);delay(6000); IOCLR1 = buz;
if(k<3)
{
k++;
goto lab2;
}
else
{
stop();
lcdcmd(0x01);
disp_loc(0x80,"Vehicle is blocked");
send("+918008407294"); delay(1000);
uart_tx_str("Ur vehicle is blocked");
uart_tx_char(0x1a);delay(1000);
IOSET1 = buz;delay(6000);delay(6000);delay(6000); IOCLR1 = buz;
while(1);
}
}
delay(10000);delay(10000);delay(10000);delay(10000);
}
}
void uart1(void)
{
U1LCR=0x83;
U1FCR=0x07;
U1DLL=0xC3;
U1LCR=0x03;
VICIntEnable=1<<7;
U1IER=0x01;
VICVectCntl1=0x00000027;
VICVectAddr1=(unsigned)interrupt_serial;
}
void eng(void)
{
if(((IOPIN0 & 0x00001000)==0x00000000) |((IOPIN0 & 0x0000F000)==0x0000E000))
{
disp_loc(0xc0,"Vehicle moving ");IOSET0 = motor1;IOSET0 = motor3;
}
else if(((IOPIN0 & 0x00001000)==0x00001000) |((IOPIN0 & 0x0000F000)==0x0000F000))
{
disp_loc(0xc0,"Vehicle stopped");IOCLR0 = motor1;IOCLR0 = motor3;
}
}
void start(void)
{
IOSET0=motor1 ;
IOSET0=motor3;
}
void stop(void)
{
IOCLR0=motor1;
IOCLR0=motor3;
}
void con(unsigned int x)
{
unsigned char y,z;
unsigned char d0,d1,d2;
y=x/10;
d0=x%10;
d1=y%10;
d2=y/10;
z=d2*100+d1*10+d0;
lcddata(d2+0x30);
delay(100);
lcddata(d1+0x30);
delay(100);
lcddata(d0+0x30);
delay(100);
}
void clear(void)
{
for(i=0;i<100;i++)
{
c[i]='\0';
d[i]='\0';
}
}
void clear1(void)
{
for(i=0;i<20;i++)
{
sms[i]='\0';
lt[i]='\0';
ln[i]='\0';
}
}