GPS LCD

Använd en LCD-skärm för att skriva ut GPS-koordinater.

gps lcd maker !!!.jpg


Fritzing layout

34 gps lcd

OBS ladda ner TinyGPS biblioteket här:  press here


Arduino kod

/*
Instructions from dfrobot.com

LCD connections 
VSS to GND
VDD to +5V
VO to 10k pot viper
RW to GND

GPS module connections

green to TX
blue to RX
red to +3.3V
yellow to 3.3V
black to GND

*/


#include <TinyGPS.h>
#include <LiquidCrystal.h>
 
TinyGPS gps;
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);  //LCD driver pins (RS,E,D4,D5,D6,D7)
int led = 13;
 
long lat, lon;
unsigned long fix_age, time, date, speed, course;
unsigned long chars;
unsigned short sentences, failed_checksum;
//int year;
//byte month, day, hour, minute, second, hundredths;
 
int DEG;
int MIN1;
int MIN2;
  
void LAT(){                       //Latitude state
  DEG=lat/1000000;
  MIN1=(lat/10000)%100;
  MIN2=lat%10000;
 
  lcd.setCursor(0,0);             // set the LCD cursor   position 
  lcd.print("LAT:");              
  lcd.print(DEG);
  lcd.write(0xDF);
  lcd.print(MIN1);
  lcd.print(".");
  lcd.print(MIN2);
  lcd.print("'   ");
}
void LON(){                        //Longitude state
  DEG=lon/1000000;
  MIN1=(lon/10000)%100;
  MIN2=lon%10000;
 
  lcd.setCursor(0,1);              // set the LCD cursor   position 
  lcd.print("LON:");              
  lcd.print(DEG);
  lcd.write(0xDF);
  lcd.print(MIN1);
  lcd.print(".");
  lcd.print(MIN2);
  lcd.print("'   ");
}
 
 
 
void setup()
{
  Serial.begin(9600);            //Set the GPS baud rate.
 
  pinMode(led, OUTPUT);  
 
  lcd.begin(16, 2);               // start the library
  lcd.setCursor(0,0);             // set the LCD cursor   position 
  lcd.print("GPS test");          // print a simple message on the LCD 
  delay(2000);
}
 
void loop()
{
  while (Serial.available())
  {
    digitalWrite(led, HIGH);
    int c = Serial.read();                   // Read the GPS data
    if (gps.encode(c))                        // Check the GPS data
    {
      // process new gps info here
    }
 
  }
  digitalWrite(led, LOW);
  gps.get_position(&lat, &lon, &fix_age);     // retrieves +/- lat/long in 100000ths of a degree
  gps.get_datetime(&date, &time, &fix_age);   // time in hhmmsscc, date in ddmmyy
 
  //gps.crack_datetime(&year, &month, &day,    //Date/time cracking
  //&hour, &minute, &second, &hundredths, &fix_age);  
 
LAT();
LON();
 
}

Länk till hemsida för att kontrollera om koordinaterna stämmerPress heresattelit bild vörå.jpg

Steg 2 av projektet: 

Nästa steg är att få arduino att göra något när GPS:en byter värde, T.ex att tända en lampa. I koden nedan så är det inställt så att när värdet av Latitude MIN1 är = 13 så tänds lampan. Att använda en lampa var bara ett exempel, man kan fast få den att spela ett ljud eller något annat, fantasin sätter gränserna. Här slutar jag med mitt projekt men arbeta gärna vidare på det själv!IMG_20180523_091654.jpg

 

/*
Instructions from dfrobot.com

LCD connections 
VSS to GND
VDD to +5V
VO to 10k pot viper
RW to GND

GPS module connections

green to TX
blue to RX
red to +3.3V
yellow to 3.3V
black to GND

*/


#include <TinyGPS.h>
#include <LiquidCrystal.h>
 
TinyGPS gps;
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);  //LCD driver pins (RS,E,D4,D5,D6,D7)

int ledpin = 8; 
bool state;
long lat, lon;
unsigned long fix_age, time, date, speed, course;
unsigned long chars;
unsigned short sentences, failed_checksum;
//int year;
//byte month, day, hour, minute, second, hundredths;
 
int DEG;
int MIN1;
int MIN2;
  
void LAT(){                       //Latitude state
  DEG=lat/1000000;
  MIN1=(lat/10000)%100;
  MIN2=lat%10000;
 
  lcd.setCursor(0,0);             // set the LCD cursor   position 
  lcd.print("LAT:");              
  lcd.print(DEG);
  lcd.write(0xDF);
  lcd.print(MIN1);
  lcd.print(".");
  lcd.print(MIN2);
  lcd.print("'   ");
  if(MIN1 == 13)
  {
    state = HIGH;
  }
  else 
  { 
    state = LOW;
  }
}
void LON(){                        //Longitude state
  DEG=lon/1000000;
  MIN1=(lon/10000)%100;
  MIN2=lon%10000;
 
  lcd.setCursor(0,1);              // set the LCD cursor   position 
  lcd.print("LON:");              
  lcd.print(DEG);
  lcd.write(0xDF);
  lcd.print(MIN1);
  lcd.print(".");
  lcd.print(MIN2);
  lcd.print("'   ");
}
 
 
 
void setup()
{

  pinMode(ledpin, OUTPUT);

  Serial.begin(9600);            //Set the GPS baud rate.
 
  pinMode(ledpin, OUTPUT);  
 
  lcd.begin(16, 2);               // start the library
  lcd.setCursor(0,0);             // set the LCD cursor   position 
  lcd.print("GPS test");          // print a simple message on the LCD 
  delay(2000);
}
 
void loop()
{
  while (Serial.available())
  {
   
    int c = Serial.read();                   // Read the GPS data
    if (gps.encode(c))                        // Check the GPS data
    {
      // process new gps info here
    }
 
  }
  
  gps.get_position(&lat, &lon, &fix_age);     // retrieves +/- lat/long in 100000ths of a degree
  gps.get_datetime(&date, &time, &fix_age);   // time in hhmmsscc, date in ddmmyy
 
  //gps.crack_datetime(&year, &month, &day,    //Date/time cracking
  //&hour, &minute, &second, &hundredths, &fix_age);  
 
LAT();
LON();
digitalWrite(ledpin, state);
 
}

 

2 thoughts on “GPS LCD

Leave a comment