Writing GPS date to SD card

I am trying to write the GPS data from a Dexter industries How to Use the Arduino GPS Shield For the First Time For Beginners
with a nano. with this code

  This program demonstrates the dGPS library from Dexter Industries for Arduino

  For use with the Dexter Industries GPS Shield.  The dGPS can be found here:
   - http://dexterindustries.com/Arduino-GPS_Shield.html

  This code was originally based on the work of others.  You can see the original work here:
   - SoftwareSerial Library:  http://www.arduino.cc/en/Reference/SoftwareSerial
   - GPS Tutorial:  http://www.arduino.cc/playground/Tutorials/GPS

  See our Arduino GPS Converting Coordinates for information on converting coordinates
  from GPS Style Coordinates (ddmm.ssss) to Decimal Style Coordinates (dd.mmssss).

  How it works:
   - The dGPS requires the SoftwareSerial.h library.
   - The GPS is initialized in the setup function.
   - The GPS is updated: values for location, time, etc, are updated using the ".update" function.
   - The values are read using their respective calls.  These values stay the same until "update" is called again.

  Simplified by Jeff Conrad to just show the specific current measurements, no destination.

#include "string.h"
#include "ctype.h"
#include "SoftwareSerial.h"
#include "dGPS.h"
#include <SPI.h>
#include <SD.h>

File myFile;

// Software serial TX & RX Pins for the GPS module
// Initiate the software serial connection
int ledPin = 13;                  // LED test pin
dGPS dgps = dGPS();               // Construct dGPS class

void setup() {

  pinMode(8, OUTPUT);

  Serial.end();                  // Close any previously established connections
  Serial.begin(9600);            // Serial output back to computer.  On.
  dgps.init();                   // Run initialization routine for dGPS.

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    while (1);
    Serial.println("initialization done.");


void loop() {

  dgps.update(0, 0);

  Serial.print("Latitude: ");
  Serial.print(dgps.Lat(), 6);    // Latitude - in DD.MMSSSS format (decimal-degrees format)  (D-Degree; M-Minute; S-Second)
  Serial.println(" degrees");

  Serial.print("Longitude: ");
  Serial.print(dgps.Lon(), 6);    // Longitude - in DD.MMSSSS format (decimal-degrees format)  (D-Degree; M-Minute; S-Second)
  Serial.println(" degrees");
  /*Serial.print("UTC Date(DDMMYY): ");
  Serial.println(dgps.Date());    // UTC date.  Date is in format:  DDMMYY (D - Day; M - Month; Y-Year)

  Serial.print("UTC Time: ");
  Serial.println(dgps.Time());    // .Time returns the UTC time (GMT) in HHMMSS, 24 huor format (H-Hour; M-Minute; S-Second)

  Serial.print("Status: ");
  Serial.println(dgps.Status());  // A - Satellites acquired and a valid signal.  V - No sats and not a valid signal.

  Serial.print("Velocity: ");
  Serial.print(dgps.Vel(), 6);    // Velocity, in knots.
  Serial.println(" knots");

  Serial.print("Heading: ");
  Serial.print(dgps.Head(), 6);   // Heading, in degrees
  Serial.println(" degrees");

  Serial.print("Received CheckSum: ");
  Serial.println(dgps.Checks()); //Checksum received from packet
  Serial.print("Computed Checksum: ");
  Serial.println(dgps.Checked(), HEX); //Checksum computed */

  //dgps.updategga();         //updates the values of Number of Satellites, HDOP and Altitude

  Serial.print("HDOP: ");
  Serial.println(dgps.Hdop());    // HDOP
  Serial.print("Altitude: ");
  Serial.print(dgps.Alti());      // Altitude (in meters) above sea-level
  Serial.println(" meters above sea level");
  Serial.print("Satellites in use: ");
  Serial.println(dgps.SatView()); // Number of Satellites in use

  if (dgps.SatView() > 0) {
    digitalWrite(8, HIGH);
    digitalWrite(8, LOW);

  myFile= SD.open("RAWLONG.txt", FILE_WRITE);
  if (myFile) {
    Serial.print("File Opened");

  myFile = SD.open("RAWLAT.txt", FILE_WRITE);
  if (myFile) {
    myFile.println(dgps.Lat(), 6);

  myFile = SD.open("RAWALT.txt", FILE_WRITE);
  if (myFile) {


when i run it it creates the file RAWLAT.txt but it doesn’t write anything it the file.

when i run it it creates the file RAWLAT.txt

The code you posted certainly does not create that file, because the relevant code is nonfunctional, given that it is “commented out” by /* … */.

This part may create and write nonsense to a different file:

  myFile= SD.open("RAWLONG.txt", FILE_WRITE);
  if (myFile) {
    Serial.print("File Opened");

A useful approach to doing something new is to write a simple program that accomplishes the outline of what you want to do, and get that working. Then add details.

That applies to getting help on the forum, as described in the helpful "How to use this forum" post. Recommended reading!