save GPS Coordinates in SD Card

hi everyone !!
I have recently buyed a GPS module . I have tested it and it is working with no issues .
Now , i wanna to log the latitude,longitude,date,time in SD Card . It should log the coordinates when GPS is fixed. (when GPS module is blinking means Active).

Here is my code ..
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <SoftwareSerial.h>
#include <TinyGPS.h>

float flat,flong; // create variable for latitude and longitude object
unsigned long date,time;
SoftwareSerial gpsSerial(7,8); // create gps sensor connection
TinyGPS gps; // create gps object

void setup(){
Serial.begin(9600); // connect serial
gpsSerial.begin(9600); // connect gps sensor
}

void loop(){
while(gpsSerial.available()){ // check for gps data
if(gps.encode(gpsSerial.read())){ // encode gps data
gps.f_get_position(&flat,&flong); // get latitude and longitude
// display position
Serial.print("Lat/Lon :"); printFloat(flat,8); Serial.print(","); printFloat(flong,8);
gps.get_datetime(&date,&time);
Serial.print("Date:"); Serial.print(date); Serial.print("Time"); Serial.print(time);
}
}
}

void printFloat(double number, int digits)
{
// Handle negative numbers
if (number < 0.0) {
Serial.print('-');
number = -number;
}

// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
rounding /= 10.0;

number += rounding;

// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
Serial.print(int_part);

// Print the decimal point, but only if there are digits beyond
if (digits > 0)
Serial.print(".");

// Extract digits from the remainder one at a time
while (digits-- > 0) {
remainder *= 10.0;
int toPrint = int(remainder);
Serial.print(toPrint);
remainder -= toPrint;
}
}

plz help me with the modifications so i can save the latitude , longitude , date , time in SD Card ..
Thanks :slight_smile:

Look at File->Examples->SD->Datalogger for how to open a file on the SD card and print to it.