Projects › Projects › vehicle tracking system using gsm and gps module › guys…my project is same as
guys…my project is same as of u with some additions…means i hav to lock/unlock door and ignition on/off…….i hav a lil bit idea about pic programing …kindly plzz help me in code i hav a code and and am able to understand some portion of code…code is given bellow
EMBEDDED C SOURCE CODE:
#include <16F877A.h>
#include <gsm.c>
#include <gps.c>
#use delay (clock=20M) //Crystal Oscillator speed 20MHz
#use rs232 (baud = 9600, xmit=PIN_B0,rcv=PIN_B1,stream=GSM) //For GSM Modem
#use rs232 (baud = 4800, xmit=PIN_A1,rcv=PIN_A0,stream=GPS) //For GPS Receiver
byte ch = 0;
int count = 0;
byte data[150]; //For SMS storage
byte wru[] = { “wru” };
byte about[] = {“about”};
byte help[] = {“help”};
byte lock[] = {“lock”};
byte unlock[] = {“unlock”};
byte num[12]; //for storing phone number
char lat[12]; //for storing latitude
char lngtd[12]; //for storing lngtd
char speed[12]; //for storing speed
char tdata[12]; //for temprary data
void main()
{
int i = 0;
int j = 0;
int flag = 0;
output_high(PIN_D1); // send “1” to pinD1
delay_ms(1000);
output_low(PIN_D1);
delay_ms(1000);
output_high(PIN_D1);
delay_ms(1000);
output_low(PIN_D1);
init_phone();
while(1)
{
output_toggle(PIN_D1); //GSM Indicator LED
delay_ms(500);
count = 0; //reset data buffer
data[count] = 0; //data[ ] is for sms storage
if(!input(PIN_C4)) //Accident Sensor switch.
{
//Crash Message Handling
output_high(PIN_D0); //LED Indicator
get_GPS_data(lat,lngtd); //Read GPS data for lat and lngtd
fprintf(GSM,”AT+CMGS=”%s”rn”,mynum); //Send SMS message to pre-defined number
fprintf(GSM,”ALERT: Vehicle No.9999 Crashed at Latitude: %s Longitude: %s rn”,lat,lngtd); //Send SMS data
fputc(0x1A,GSM); //^Z to send sms
output_low(PIN_D0); //LED Indicator
continue;
}
}
fgets(data,GSM); //Read sms data into data buffer
if(strlen(data) < 14) //No message in string. returns OK or ERROR. Depends on Modem type
{
continue;
}
//Delete the message
fprintf(GSM,”AT+CMGD=1rn”); //delete message from SIM card
delay_ms(2000);
//Read the available message content
//extract the phone number from SMS Message
get_phone_number(data,num); //extract phone number into num variable
if(strstr(data,wru)) //If the message contains “wru”
{
get_GPS_data(lat,lngtd);
output_high(PIN_D1);
fprintf(GSM,”AT+CMGS=”%s”rn”,num);
fprintf(GSM,”Hello, I am located at “);
fprintf(GSM,”Latitude: %s Longitude: %s “,lat,lngtd);
fprintf(GSM,”Speed: %s kmph. “,speed);
fprintf(GSM,”Please use Google Earth to see my location.rn”);
fputc(0x1A,GSM);
}
else if(strstr(data,about)) //If the message contains “about”
{
output_high(PIN_D1);
fprintf(GSM,”AT+CMGS=”%s”rn”,num);
fprintf(GSM,”B.Tech Final Year(2009-2010) Project rn”);
fprintf(GSM,”GPS & GSM Based Vehicle Theft Control System. rn”);
fprintf(GSM,”Engineering Final Year Project.rn”);
fputc(0x1A,GSM);
}
else if(strstr(data,unlock))
{
output_high(PIN_D1);
output_low(PIN_D7);
fprintf(GSM,”AT+CMGS=”%s”rn”,num);
fprintf(GSM,”Vehicle got unlocked”);
fputc(0x1A,GSM);
}
else if(strstr(data,lock))
{
get_GPS_data(lat,lngtd);
output_high(PIN_D1);
output_high(PIN_D7);
fprintf(GSM,”AT+CMGS=”%s”rn”,num);
fprintf(GSM,”Vehicle got locked out at location “);
fprintf(GSM,”Latitude: %s Longitude: %s “,lat,lngtd);
fprintf(GSM,”Please use Google Earth to see my location.rn”);
fputc(0x1A,GSM); //^Z
}
else if(strstr(data,help))
{
output_high(PIN_D1);
fprintf(GSM,”AT+CMGS=”%s”rn”,num);
fprintf(GSM,”Send “wru” to get my location rn”);
fprintf(GSM,”Send “about” to know about mern”);
fprintf(GSM,”Send “lock” to Lock the Vehicle Ignition.rn”);
fprintf(GSM,”Send “unlock” to Unlock.rn”);
fputc(0x1A,GSM);
}
}
}