Troubles with GPS

I’m doing a school project where I’m making a device that gets it’s own location coordinates and displays them on LCD. Since I’m not experienced with Arduino, I chose to follow a tutorial for my device. However the tutorial I picked is very bad, and it’s unfortunately too late to choose another. The tutorial is here. Through a lot of extra research on things the tutorial should have mentioned, I managed to assemble the device. However, the code provided by the tutorial does not work properly.

// Creating a Simple GPS Receiver
#include <TinyGPS.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );
// Create an instance of the TinyGPS object
TinyGPS gps;
void getgps(TinyGPS &gps);
void setup()
{
Serial.begin(4800);
lcd.begin(16, 2);
}
void getgps(TinyGPS &gps)
// The getgps function will display the required data on the LCD
{
float latitude, longitude;
//decode and display position data
gps.f_get_position(&latitude, &longitude);
lcd.setCursor(0,0);
lcd.print("Lat:");
lcd.print(latitude,5);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("Long:");
lcd.print(longitude,5);
lcd.print(" ");
delay(3000); // wait for 3 seconds
lcd.clear();
}
void loop()
{
byte a;
if ( Serial.available() > 0 ) // if there is data coming into the serial line
{
a = Serial.read(); // get the byte of data
if(gps.encode(a)) // if there is valid GPS data...
{
getgps(gps); // grab the data and display it on the LCD
}
}
}

The code above is what the tutorial provided. When I try to compile it, it gives me the following error

Arduino: 1.8.1 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Users\(My computer)\Documents\FSID3LEHVLYA77X\FSID3LEHVLYA77X.ino:2:21: fatal error: TinyGPS.h: No such file or directory

 #include <TinyGPS.h>

                     ^

compilation terminated.

exit status 1
Error compiling for board Arduino/Genuino Uno.

The parts I used are the Arduino Uno R3, the Sparkfun 16x2 LCD, and the Sparkfun GPS shield.

I’m not really sure how to fix this, and my deadline is only getting closer. Any help would be greatly appreciated.

However the tutorial I picked is very bad, and it's unfortunately too late to choose another.

This is nonsense.

It's not because you picked a supposedly bad tutorial that you are stuck with it for the rest of you're life. Find another one and write your own code and you'll be in control.

To your specific problem - Have you installed the TinyGPS library on your PC?

Person-Mann:
Through a lot of extra research on things the tutorial should have mentioned

There may be something wrong with your setup.

Whilst you might be expecting (hoping ?) the tutorial will cover every single aspect of getting the project working thats unlikley to be the case.

If it were then the tutorial would likley have to start on;

  1. First we need to install Windows ..........

If it were then the tutorial would likley have to start on;

  1. First we need to install Windows Linux..........

However the tutorial I picked is very bad…

This should have been your first clue that it is very bad: "Hi frenzzz… "

…it’s unfortunately too late to choose another.

I guess you’re stuck. Wait…

Here’s a NeoGPS version of your sketch:

// Creating a Simple GPS Receiver
#include <NMEAGPS.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );
NMEAGPS gps;

void setup()
{
  Serial.begin(4800);
  lcd.begin(16, 2);
}

void getgps( NMEAGPS &gps )
// The getgps function will display the required data on the LCD
{
  gps_fix fix = gps.read(); // grab the data
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Lat:");
  lcd.print( fix.latitude(), 5 );
  lcd.print(" ");
  lcd.setCursor(0,1);
  lcd.print("Long:");
  lcd.print( fix.longitude(),5 );
  lcd.print(" ");
}

void loop()
{
  if (gps.available( Serial )) // if there is valid GPS data...
  {
    getgps(gps); // grab the data and display it on the LCD
  }
}

Using indentation and a few blank lines makes it so much more readable! Just press control-T in the IDE editor.

Using a delay can also cause trouble. It will make your Arduino lose the data coming from the GPS device. You may not get a lat/lon at all, especially with that library.

If you only want to update the display once every 3 seconds, just count the fixes. They arrive at exactly once per second. Do something like this in getgps:

int fixCount = 0;

void getgps( NMEAGPS &gps )
// The getgps function will display the required data on the LCD
{
  gps_fix fix = gps.read(); // grab the data
  
  fixCount = fixCount+1;

  if (fixCount == 3) {
    fixCount = 0; // reset counter

    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Lat:");
    lcd.print( fix.latitude(), 5 );
    lcd.print(" ");
    lcd.setCursor(0,1);
    lcd.print("Long:");
    lcd.print( fix.longitude(),5 );
    lcd.print(" ");
  }
}

Also, using NeoGPS saves a lot of program space and RAM:

Your original sketch uses 7804 bytes of program space and 407 bytes of RAM (almost half!).
The NeoGPS sketch can be as small as 7214 bytes of program space and 286 bytes of RAM.

If you want to try it, NeoGPS is available from the Arduino IDE Library Manager, under the menu Sketch → Include Library → Manage Libraries.

Cheers,
/dev