#include <string.h>
#include <ctype.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 6); // RX, TX
char fy=0;
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 7; // the number of the pushbutton pin
int buttonState1 = 0; // variable for reading the pushbutton status
int buttonState2 = 0; // variable for reading the pushbutton status
int buttonState3 = 0; // variable for reading the pushbutton status
int ledPin = 8; // LED test pin
int rxPin = 0; // RX PIN
int txPin = 1; // TX TX
int byteGPS=-1;
char linea[300] = "";
char lat[30] = "";
char lon[30] = "";
char comandoGPR[7] = "$GPRMC";
int cont=0;
int bien=0;
int conta=0;
int indices[13];
int sensorValue1 = 0; // variable to store the value coming from the sensor
int sensorValue2 = 0; // variable to store the value coming from the sensor
int sensorValue3 = 0; // variable to store the value coming from the sensor
int sensorValue4 = 0; // variable to store the value coming from the sensor
int sensorValue5 = 0; // variable to store the value coming from the sensor
int sensorValue6 = 0; // variable to store the value coming from the sensor
int sensorValue7 = 0; // variable to store the value coming from the sensor
int cnt = 0,fl=0,i; // variable to store the value coming from the sensor
long duration, inches, cm,distance;
int hb,hbt,hbtt,boc,finc;
char kval;
int bhb,bhbt,bhbtt;
void txs(unsigned char val)
{
int i;
Serial.write(val);
for(i=0;i<1200;i++);
}
char f1,f2,f3,oc;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
pinMode (2,OUTPUT);//attach pin 2 to vcc
pinMode (3,OUTPUT);//attach pin 2 to vcc
pinMode (4,INPUT_PULLUP);//attach pin 5 to GND
digitalWrite(2,0);
digitalWrite(3,1);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("BIKE ");
lcd.setCursor(0, 1);
lcd.print("SECURITY ");
Serial.print("AT");
Serial.write(13);
Serial.write(10);
delay(1000);
Serial.print("AT+CMGF=1");
Serial.write(13);
Serial.write(10);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("Show ");
lcd.setCursor(0, 1);
lcd.print("Finger ");
}
long ll;
void loop() {
if (mySerial.available()) {
lcd.setCursor(15, 1);
kval=mySerial.read();
lcd.print(kval);
if(kval=='0')
{
finc=2;
lcd.setCursor(0, 0);
lcd.print("Unauthorised ");
lcd.setCursor(0, 1);
lcd.print(" ");
digitalWrite(3,0);
}
else
{
digitalWrite(2,1);
lcd.setCursor(0, 0);
lcd.print("Authorised ");
lcd.setCursor(0, 1);
lcd.print(" ");
digitalWrite(3,1);
}
}
if(finc==2)
{
digitalWrite(2,0);
if(f1==0)
{
digitalWrite(3,0);
f1=1;
Serial.print("AT");
Serial.write(13);
Serial.write(10); delay(1000);
Serial.print("AT+CMGS=");
Serial.write(34);
Serial.print("7748720606");
Serial.write(34);
Serial.write(13);
Serial.write(10);
delay(1000);
Serial.print("UnAuthorised");
Serial.write(13);
Serial.write(10);
txs(' ');txs(' ');
txs(lat[0]);
txs(lat[1]);
txs(lat[2]);
txs(lat[3]);
txs(lat[4]);
txs(lat[5]);
txs(lat[6]);
txs(lat[7]);
txs(' ');
txs(' ');txs(' ');
txs(lon[0]);
txs(lon[1]);
txs(lon[2]);
txs(lon[3]);
txs(lon[4]);
txs(lon[5]);
txs(lon[6]);
txs(lon[7]);
Serial.write(26);
delay(5000);
digitalWrite(3,1);
}
}
while(i<150)
{
if (Serial.available() > 0)
{
linea[i]=Serial.read(); // Read a byte of the serial port
i++;
}
}
for (int i=0;i<100;i++){ //
//Serial.print(linea[i]);
if(linea[i]=='G')
if(linea[i+1]=='P')
if(linea[i+2]=='R')
if(linea[i+3]=='M')
if(linea[i+4]=='C')
{
lat[0]=linea[i+19];
lat[1]=linea[i+20];
lat[2]=linea[i+21];
lat[3]=linea[i+22];
lat[4]=linea[i+23];
lat[5]=linea[i+24];
lat[6]=linea[i+25];
lat[7]=linea[i+26];
lon[0]=linea[i+31];
lon[1]=linea[i+32];
lon[2]=linea[i+33];
lon[3]=linea[i+34];
lon[4]=linea[i+35];
lon[5]=linea[i+36];
lon[6]=linea[i+37];
lon[7]=linea[i+38];
}
}
i=0;
}
Comments
Post a Comment