GPS Module + LCD printing data issues

Hey everyone, I have a GPS module that I have working and printing out the data to the serial monitor that is accurate. What I am trying to do now is parse that data using the TinyGPS library that is explained here: TinyGPS | Arduiniana
Here is my code:

  #if (ARDUINO >= 100)
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);
  #else
// If you're using Arduino IDE v23 or earlier, you'll
// need to install NewSoftSerial
#include <NewSoftwareSerial.h>
NewSoftwareSerial mySerial(2, 3);
  #endif
  
#include "TinyGPS.h"
TinyGPS gps;


#define PMTK_SET_NMEA_UPDATE_1HZ  "$PMTK220,1000*1F"
#define PMTK_SET_NMEA_UPDATE_5HZ  "$PMTK220,200*2C"
#define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);

void setup()  
{
  Serial.begin(57600);
  Serial.println("Adafruit MTK3329 NMEA test!");
  

  // 9600 NMEA is the default baud rate
  mySerial.begin(9600);

  // uncomment this line to turn on all the available data - for 9600 baud you'll want 1 Hz rate
  mySerial.println(PMTK_SET_NMEA_OUTPUT_RMCONLY);
  
  // Set the update rate
  // 1 Hz update rate
 // mySerial.println(PMTK_SET_NMEA_UPDATE_1HZ);
  // 5 Hz update rate- for 9600 baud you'll have to set the output to RMC only (see above)
  mySerial.println(PMTK_SET_NMEA_UPDATE_5HZ);
  // 10 Hz update rate - for 9600 baud you'll have to set the output to RMC only (see above)
  //mySerial.println(PMTK_SET_NMEA_UPDATE_10HZ);

  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.clear();
  lcd.print("Welcome!");
}

void loop()                     // run over and over again
{
   
  
  if (mySerial.available())
  {
    Serial.print((char)mySerial.read());
  }  
  
  /*while (mySerial.available())
  {
      
      int c = mySerial.read();
       if (gps.encode(c))
    {
      long lat, lon;
      unsigned long fix_age, time, date, speed, course;
      unsigned long chars;
      unsigned short sentences, failed_checksum;

      // retrieves +/- lat/long in 100000ths of a degree
      gps.get_position(&lat, &lon, &fix_age);

      // time in hhmmsscc, date in ddmmyy
      gps.get_datetime(&date, &time, &fix_age);

      // returns speed in 100ths of a knot
      speed = gps.speed();

      // course in 100ths of a degree
      course = gps.course();
    
      
     //Setup the dashbard
     lcd.clear();
     lcd.setCursor(0, 0);
     //lcd.print("Spd:");
     lcd.print(speed);
    }
  }
   */
      
}

That current code will properly display the data through the serial monitor. If take out that large comment then it will give bad data to the serial monitor. If I change the " if (mySerial.available)" to a “while (mySerial.available)” It will print out data which I think is correct on the LCD screen but it wont print to the serial monitor so I can verify.

Basically what I want it to do is print to the serial monitor all the data, and print parsed data to the LCD screen so I can verify that it’s parsing correctly. If you can figure out what I am doing wrong I would greatly appreciate it. I don’t know much about libraries and I am a very terrible programmer.

Thanks all!!!

The commented out code reads, stores, and prints the data to the LCD. The non-commented out code reads and prints the data to the serial port.

You can't have both block of code in the same sketch, since the process of reading the serial data removes it from the buffer.

You could add

Serial.print(c);

in the commented out block, after deleting the non-commented code and uncommenting the commented out code.