TechnicalEngineer
Published © GPL3+

Traffic Surveillance System Using MATLAB and Arduino

Traffic Surveillance System is demonstrated by way of how the traffic could be controlled directly from the traffic control room.

IntermediateFull instructions provided1,525
Traffic Surveillance System Using MATLAB and Arduino

Story

Read more

Schematics

Traffic Surveillance System using MATLAB and Arduino

Code

Source Code -- Traffic Surveillance System using MATLAB and Arduino

C Header File
//#include<LiquidCrystal.h>
//LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

char str[70];
char *test="$GPGGA";      
char logitude[10];
char latitude[10];

int In=8;
//int LED=8;

int i,j,k;
int temp;
//int Ctrl+z=26;    //for sending msg

void setup()
{
//  lcd.begin(16,2);
  Serial.begin(9600);
  pinMode(In, INPUT);
//  pinMode(LED, OUTPUT);
//  lcd.setCursor(0,0);
//  lcd.print("     trafic    ");
//  lcd.setCursor(0,1);
//  lcd.print("   survilience ");
//  delay(4000);
}

void loop()
{
  
  while(digitalRead(In) != 1);
  if (temp==1)
  {
    for(i=18;i<27;i++)          //extract latitude from string
    {
      latitude[j]=str[i];
      j++;
    }
   
    for(i=30;i<39;i++)          //extract longitude from string
    {
      logitude[k]=str[i];
      k++;
    }
   
   // lcd.setCursor(0,0);        //display latitude and longitude on 16X2 lcd display 
   // lcd.print("Lat(N)");
   // lcd.print((unsigned)latitude);
   // lcd.setCursor(0,1);
   // lcd.print("Lon(E)");
   // lcd.print((unsigned)logitude);
   // delay(100);
   // digitalWrite(LED, HIGH);
    Serial.println("AT+CMGF=1");    //select text mode
    delay(10);
    Serial.println("AT+CMGS=\"9610126059\"");  // enter receipent number
    Serial.println("Trafic Jam ");
    Serial.print("Latitude(N): ");             //enter latitude in msg
    Serial.println(latitude); 
    Serial.print("Longitude(E): ");            //enter Longitude in Msg
    Serial.println(logitude); 
                    //enter latitude value in msg
                    //enter longitude value in msg
    Serial.println("Thanks");  
    Serial.write(26);                      //send msg  Ctrl+z=26
    temp=0;
    i=0;
    j=0;
    k=0;
    delay(4000);                        // next reading within 20 seconds
   // digitalWrite(LED, LOW);
}
}

void serialEvent()
{
  while (Serial.available())            //Serial incomming data from GPS
  {
    char inChar = (char)Serial.read();
     str[i]= inChar;                    //store incomming data from GPS to temparary string str[]
     i++;
     if (i < 7)                      
     {
      if(str[i-1] != test[i-1])         //check for right string
      {
        i=0;
      }
     }
    if(i >=60)
    {
     temp=1;
    }
  }
}

Credits

TechnicalEngineer
4 projects • 51 followers
Contact

Comments

Please log in or sign up to comment.