#include <TinyGPS.h>
TinyGPS gps;
#include <SoftwareSerial.h>
SoftwareSerial ss(3,2); //tx rx pinleri bağlanır // doğru olan bu
const int trigger_pin =10;
const int echo_pin = 11;
int sure;
float engelmesafe;
void setup() {
pinMode(trigger_pin, OUTPUT);
pinMode(echo_pin, INPUT);
Serial.begin(9600);
ss.begin(9600);
}
void loop() {
digitalWrite(trigger_pin, HIGH);
delayMicroseconds(10);
digitalWrite(trigger_pin, LOW);
sure = pulseIn(echo_pin, HIGH);
engelmesafe = (sure/2) / 29.1;
Serial.print("\nMesafe = ");
Serial.println(engelmesafe);
smartdelay(500);
Serial.println();
float flat, flon,distance;
unsigned long age;
gps.f_get_position(&flat, &flon);
Serial.print("x koordinatı: "); Serial.println(flat, 6);
Serial.print("y koordinatı: "); Serial.println(flon, 6);
float hiz = gps.f_speed_kmph();
Serial.print("Hız: "); Serial.println(hiz);
const char* yon = gps.cardinal(gps.course_to(flat, flon, 40.541502, 41.979748));
//char yon =gps.cardinal(gps.f_course()) ;
//Serial.print("Yön: "); Serial.println(gps.cardinal(gps.course_to(flat, flon, 40.541502, 41.979748)));
Serial.print("mesafe : "); Serial.println( gps.distance_between(flat , flon ,40.541502 , 41.979748 ));
Serial.print("yön: "); Serial.println(yon);
}
static void smartdelay(unsigned long ms) {
unsigned long start = millis();
do {
while (ss.available())
gps.encode(ss.read());
} while (millis() - start < ms);
}