Arduino Konum Takip Projesi

Arduino Konum Takip Projesi

Arduino projelerime devam ederken sırayı konum takip sistemi almaktadır. Konum takip devresi baret üzerine montaj yapılarak bareti takan kişinin konumunun tespiti sağlanmaktadır. Ayrıca sıcaklık nem ve gaz bilgileri de hem lcd ekrana hemde android telefona aktarılmaktadır.Umarım hoşunuza gider arkadaşlar.


 

 

 

#include <TinyGPS++.h>
#include <SoftwareSerial.h>

//                      TX, RX
SoftwareSerial mySerial(0, 1);
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
TinyGPSPlus gps;
SoftwareSerial ss(RXPin, TXPin);
float N;
float E;

#include <LiquidCrystal.h>

#include <dht11.h>
dht11 DHT11;

//               (Rs, E, D4, D5, D6 ,D7)
LiquidCrystal lcd(12 , 11, 10 , 9 , 8 , 7);

int isi;
int isi_ref;
int gaz;
int gaz_ref;
int gaz_okunan;
int gaz_okunan_deger;
float sicaklik;
int baret;
float nem;
#define buzzer 13
#define far 2
#define led 6

void setup()
{
  Serial.begin(9600);
  ss.begin(GPSBaud);

  pinMode(buzzer, OUTPUT);
  pinMode(far, OUTPUT);
  pinMode(led, OUTPUT);
  digitalWrite(buzzer, LOW);
  digitalWrite(far, LOW);
  digitalWrite(led, HIGH);

  lcd.begin(16, 2);
  DHT11.attach(5);
//  Serial.println("DHT11 TEST PROGRAM ");
//  Serial.print("LIBRARY VERSION: ");
//  Serial.println(DHT11LIB_VERSION);
  lcd.clear();
  lcd.setCursor (0, 0);
  lcd.println("TEHLIKE VE KONUM");
  lcd.setCursor (0, 1);
  lcd.println(" TAKIP  PROJESI ");
  delay(2000);
}

void loop()
{
  static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;
  unsigned long distanceKmToLondon =
    (unsigned long)TinyGPSPlus::distanceBetween(
      gps.location.lat(),
      gps.location.lng(),
      LONDON_LAT,
      LONDON_LON) / 1000;

  double courseToLondon =
    TinyGPSPlus::courseTo(
      gps.location.lat(),
      gps.location.lng(),
      LONDON_LAT,
      LONDON_LON);
  const char *cardinalToLondon = TinyGPSPlus::cardinal(courseToLondon);
  smartDelay(1000);
  if (millis() > 5000 && gps.charsProcessed() < 10){
//    Serial.println(F("No GPS data received: check wiring"));
  }
  N = gps.location.lat();
  E = gps.location.lng();

  baret = analogRead(A4);

  isi = analogRead(A2);
  isi_ref = map(abs(isi), 0, 1024, 99, 0);

  gaz = analogRead(A3);
  gaz_ref = map(abs(gaz), 0, 1024, 99, -1);

  gaz_okunan = analogRead(A1);
  gaz_okunan_deger = map(abs(gaz_okunan), 0, 1024, 0, 100);

  int chk = DHT11.read();
//  Serial.print("Nem (%): ");
//  Serial.println((float)DHT11.humidity, DEC);
//
//  Serial.print("SICAKLIK (°C): ");
//  Serial.println((float)DHT11.temperature, DEC);
  sicaklik = (float)DHT11.temperature, DEC;
nem = (float)DHT11.humidity, DEC;
  
  lcd.clear();
  lcd.setCursor (0, 0);
  lcd.print("N = ");
  lcd.print(N, 6);
  lcd.print("     ");
  lcd.setCursor (0, 1);
  lcd.print("E = ");
  lcd.print(E, 6);
  lcd.print("     ");
  delay(2000);
  lcd.clear();



  lcd.setCursor (0, 0);
  lcd.print("SIC(r)GAZ(r)%NEM");
  lcd.setCursor (0, 1);
  lcd.print((int)DHT11.temperature, DEC);
  lcd.setCursor (2, 1);
  lcd.print("-");
  lcd.setCursor (3, 1);
  lcd.print(isi_ref);
  lcd.setCursor (5, 1);
  lcd.print("|");

  lcd.setCursor (6, 1);
  lcd.print(gaz_okunan_deger);
  lcd.setCursor (8, 1);
  lcd.print("-");
  lcd.setCursor (9, 1);
  lcd.print(gaz_ref);
  lcd.setCursor (11, 1);
  lcd.print("|  ");

  lcd.setCursor (14, 1);
  lcd.print((int)DHT11.humidity, DEC);


  delay(2000);
while (baret > 350)
  {  

  Serial.print(N, 6);
  Serial.print(",");
  Serial.print(E, 6);
  Serial.print(",");
  Serial.print(sicaklik);
  Serial.print(",");
  Serial.print(nem);
  Serial.print(",");
  Serial.print(gaz_okunan_deger);
  Serial.print(",");
  Serial.println("BARET TAKILMADI");
    
    lcd.setCursor (0, 0);
    lcd.print(" CAN  GUVENLIGI ");
    lcd.setCursor (0, 1);
    lcd.print("      ICIN      ");
     delay(1000);
    lcd.setCursor (0, 0);
    lcd.print(" LUTFEN  BARETI ");
    lcd.setCursor (0, 1);
    lcd.print("    TAKINIZ     ");
     delay(1000);

    digitalWrite(buzzer, HIGH);
    digitalWrite(far, HIGH);
    delay(50);
    digitalWrite(buzzer, LOW);
    digitalWrite(far, LOW);
    delay(100);
  baret = analogRead(A4);
  }

  while (gaz_okunan_deger > gaz_ref)
  {

    lcd.setCursor (0, 0);
    lcd.print("(c)GAZ YUKSEK(r)");
    lcd.setCursor (0, 1);
    lcd.print(gaz_okunan_deger);
    lcd.print("  ");
    lcd.setCursor (3, 1);
    lcd.print(" SEVIYEDE ");
    lcd.setCursor (14, 1);
    lcd.print( gaz_ref);

    digitalWrite(buzzer, HIGH);
    digitalWrite(far, HIGH);
    delay(50);
    digitalWrite(buzzer, LOW);
    digitalWrite(far, LOW);
    delay(100);
    isi = analogRead(A2);
    isi_ref = map(abs(isi), 0, 1024, 99, 0);

    gaz = analogRead(A3);
    gaz_ref = map(abs(gaz), 0, 1024, 99, -1);

    gaz_okunan = analogRead(A1);
    gaz_okunan_deger = map(abs(gaz_okunan), 0, 1024, 0, 100);

  Serial.print(N, 6);
  Serial.print(",");
  Serial.print(E, 6);
  Serial.print(",");
  Serial.print(sicaklik);
  Serial.print(",");
  Serial.print(nem);
  Serial.print(",");
  Serial.print(gaz_okunan_deger);
  Serial.print(",");
  Serial.println("GAZ TEHLİKESİ");
  }

  digitalWrite(buzzer, LOW);
  digitalWrite(far, LOW);
  while (sicaklik > isi_ref)
  {
    int chk = DHT11.read();
    lcd.setCursor (0, 0);
    lcd.print("(c)ISI YUKSEK(r)");
    lcd.setCursor (0, 1);
    lcd.print((int)DHT11.temperature, DEC);
    lcd.print("  ");
    lcd.setCursor (3, 1);
    lcd.print(" SEVIYEDE ");
    lcd.setCursor (14, 1);
    lcd.print(isi_ref);

  digitalWrite(buzzer, HIGH);
    digitalWrite(far, HIGH);
    delay(50);
    digitalWrite(buzzer, LOW);
    digitalWrite(far, LOW);
    delay(100);
    isi = analogRead(A2);
    isi_ref = map(abs(isi), 0, 1024, 99, 0);

    gaz = analogRead(A3);
    gaz_ref = map(abs(gaz), 0, 1024, 99, -1);

    gaz_okunan = analogRead(A1);
    gaz_okunan_deger = map(abs(gaz_okunan), 0, 1024, 0, 100);

 sicaklik = (float)DHT11.temperature, DEC;

   Serial.print(N, 6);
  Serial.print(",");
  Serial.print(E, 6);
  Serial.print(",");
  Serial.print(sicaklik);
  Serial.print(",");
  Serial.print(nem);
  Serial.print(",");
  Serial.print(gaz_okunan_deger);
  Serial.print(",");
  Serial.println("ISI TEHLİKESİ");
  }

  digitalWrite(buzzer, LOW);
  digitalWrite(far, LOW);
  

  Serial.print(N, 6);
  Serial.print(",");
  Serial.print(E, 6);
  Serial.print(",");
  Serial.print(sicaklik);
  Serial.print(",");
  Serial.print(nem);
  Serial.print(",");
  Serial.print(gaz_okunan_deger);
  Serial.print(",");
  Serial.println("NORMAL");
 

}


static void smartDelay(unsigned long ms)
{
  unsigned long start = millis();
  do
  {
    while (ss.available())
      gps.encode(ss.read());
  } while (millis() - start < ms);
}


Sosyal Medyada Paylaş Facebook Twitter Google+

Etiketler: , , , ,
Eklenme Tarihi: 19 Eylül 2018

Konu hakkında yorumunuzu yazın