Problem with my program with libraries adafruit_gps.h and SD.h

hi, anyone can help me ? when i would like to write in my sd card, the program display me an error. (sorry for my english i’m french)

This program work’s :

#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
#include <math.h>

//-------------------------------VARIABLES------------------------------------------------

     double vitesseTemp = 0;
     double vitesseMax = 0;
     double vitesseTotale = 0;
     double vitesseMoyenne = 0; 
     double distance = 0;
     double temps = 0;
     double heures1 = 0;
     double minutes1 = 0;
     double secondes1 = 0;
     double heuresTot1 = 0;
     double heures2 = 0;
     double minutes2 = 0;
     double secondes2 = 0;
     double heuresTot2 = 0;
     double m = 0;
     double s = 0;
     double lat = 0;
     double latDm = 0;
     double lon = 0;
     double lonDm = 0;
     
     int p = 1;
     int H = 0;
     int M = 0;
     int S = 0;
     int k = 0;
     int startMap = 0;
     int latEnt = 0;
     int lonEnt = 0;  
    
//--------------------------------------------------------------------------------------     
     
const int chipSelect = 4;     
SoftwareSerial mySerial(8, 7);

Adafruit_GPS GPS(&mySerial);
 
#define GPSECHO  false     

boolean usingInterrupt = false;
void useInterrupt(boolean);

void setup()//---------------------------VOID-SETUP-------------------------------------  
{
  Serial.begin(115200);
  
  Serial.println("---- START ----");
  
  GPS.begin(9600);
  
  
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_10HZ);
  GPS.sendCommand(PGCMD_ANTENNA);
  
  useInterrupt(true);

  delay(1000);
  
  mySerial.println(PMTK_Q_RELEASE);
}

SIGNAL(TIMER0_COMPA_vect) {
  char c = GPS.read();
 
#ifdef UDR0
  if (GPSECHO)
    if (c) UDR0 = c;  
#endif
}

void useInterrupt(boolean v) {
  if (v) {
    
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  } else {

    TIMSK0 &= ~_BV(OCIE0A);
    usingInterrupt = false;
  }
}

uint32_t timer = millis();
void loop()//-------------------------------VOID-LOOP--------------------------------------
{  
  if (! usingInterrupt) {
    char c = GPS.read();
    if (GPSECHO)
      if (c) Serial.print(c);
  }
  
  if (GPS.newNMEAreceived()) {

    if (!GPS.parse(GPS.lastNMEA())) 
      return;  
  }

  if (timer > millis())  timer = millis();

  if (millis() - timer > 3000) { 
    timer = millis();

//------------------------DATE+FIX-----------------------------------------------------------    
    Serial.print("\nDate: ");
    Serial.print(GPS.day, DEC); Serial.print('/');
    Serial.print(GPS.month, DEC); Serial.print("/20");
    Serial.println(GPS.year, DEC);
    Serial.print("Fix: "); Serial.print((int)GPS.fix);
    Serial.print(" quality: "); Serial.print((int)GPS.fixquality);
    Serial.print(" Satellites: "); Serial.println((int)GPS.satellites); 

//------------------------IF-FIX-------------------------------------------------------------
    if (GPS.fix) {

//-------------------------DMM--------------------------------------------------------------- 
    Serial.print("Localisation: ");
    Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
    Serial.print(", "); 
    Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);

//-------------------------DDD---------------------------------------------------------------     
    lat = GPS.latitude;
    lat = lat/100;
    latEnt = floor(lat);
    latDm = lat - latEnt;
    latDm = latDm * 1000;
    latDm = latDm/6;
    latDm = latDm/100;
    lat = latEnt + latDm;
     
    Serial.print("Lat : ");
    Serial.print(lat, 6);
    Serial.print(" - ");
     
    lon = GPS.longitude;
    lon = lon/100;
    lonEnt = floor(lon);
    lonDm = lon - lonEnt;
    lonDm = lonDm * 1000;
    lonDm = lonDm/6;
    lonDm = lonDm/100;
    lon = lonEnt + lonDm;
    Serial.print("Lon : ");
    Serial.println(lon, 6);
    
//----------------------------ALTITUDE--------------------------------------------------------------------    
    if((int)GPS.fixquality == 1)
    {
    Serial.print("Altitude: "); Serial.println(GPS.altitude);
    }
//----------------------------VITESSE---------------------------------------------------------------------    
     
    Serial.print("Vitesse : "); Serial.print(GPS.speed*1.85);Serial.println(" Km/h ");
      
    vitesseTemp = GPS.speed*1.85;
    if(vitesseMax < vitesseTemp)
      {
        vitesseMax = vitesseTemp;
      }
    Serial.print("Vitesse Max : ");Serial.print(vitesseMax);Serial.println(" Km/h "); 
     
    vitesseTotale = vitesseTotale + vitesseTemp;
    vitesseMoyenne = vitesseTotale / p;
    Serial.print("Vitesse Moyenne : ");Serial.print(vitesseMoyenne);Serial.println(" Km/h ");
      
    p++;

//----------------------------HEURES----------------------------------------------------------------------
    if(heuresTot1 == 0)
    {
    heures1 = GPS.hour;
    minutes1 = GPS.minute;
    secondes1 = GPS.seconds;
    heuresTot1 = heures1 + minutes1/60 + secondes1/3600;
    }
   
    heures2 = GPS.hour;
    minutes2 = GPS.minute;
    secondes2 = GPS.seconds;
    heuresTot2 = heures2 + minutes2/60 + secondes2/3600;
    
    
    Serial.print("Heures depart : ");
    Serial.print(heures1,0); Serial.print(':');
    Serial.print(minutes1,0); Serial.print(':');
    Serial.println(secondes1,0);
    
    
    Serial.print("Heure actuelle : ");
    Serial.print(GPS.hour, DEC); Serial.print(':');
    Serial.print(GPS.minute, DEC); Serial.print(':');
    Serial.println(GPS.seconds, DEC);
   
//-----------------------------------DUREE----------------------------------------------------------------
    
    temps = heuresTot2 - heuresTot1;
 
    H = floor(temps);
    m = temps - H;
    m = m * 60;
    M = floor(m);
    s = m - M;
    s = s * 60;
    S = floor(s); 
    
    Serial.print("Duree du parcours : ");Serial.print(H);Serial.print(":");Serial.print(M);Serial.print(":");Serial.println(S);
    
//----------------------------------DISTANCE--------------------------------------------------------------
    distance = vitesseMoyenne * temps;
    Serial.print("Distance parcourue : ");Serial.print(distance,3);Serial.println(" Km");
    }
  }
}

(My message was too long …)

But this program doesn’t work’s :

#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
#include <math.h>
#include <SD.h>

//-------------------------------VARIABLES------------------------------------------------

     double vitesseTemp = 0;
     double vitesseMax = 0;
     double vitesseTotale = 0;
     double vitesseMoyenne = 0; 
     double distance = 0;
     double temps = 0;
     double heures1 = 0;
     double minutes1 = 0;
     double secondes1 = 0;
     double heuresTot1 = 0;
     double heures2 = 0;
     double minutes2 = 0;
     double secondes2 = 0;
     double heuresTot2 = 0;
     double m = 0;
     double s = 0;
     double lat = 0;
     double latDm = 0;
     double lon = 0;
     double lonDm = 0;
     
     int p = 1;
     int H = 0;
     int M = 0;
     int S = 0;
     int k = 0;
     int startMap = 0;
     int latEnt = 0;
     int lonEnt = 0;  
    
//--------------------------------------------------------------------------------------     
     
const int chipSelect = 4;     
SoftwareSerial mySerial(8, 7);

Adafruit_GPS GPS(&mySerial);
 
#define GPSECHO  false     

boolean usingInterrupt = false;
void useInterrupt(boolean);

void setup()//---------------------------VOID-SETUP-------------------------------------  
{
  Serial.begin(115200);

  GPS.begin(9600);
  pinMode(10, OUTPUT);
  
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_10HZ);
  GPS.sendCommand(PGCMD_ANTENNA);

  useInterrupt(true);

  delay(1000);
  
  mySerial.println(PMTK_Q_RELEASE);
}

SIGNAL(TIMER0_COMPA_vect) {
  char c = GPS.read();
#ifdef UDR0
  if (GPSECHO)
    if (c) UDR0 = c;  
#endif
}

void useInterrupt(boolean v) {
  if (v) {
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  } else {
    TIMSK0 &= ~_BV(OCIE0A);
    usingInterrupt = false;
  }
  
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
}

uint32_t timer = millis();
void loop()//-------------------------------VOID-LOOP--------------------------------------
{  
  if (! usingInterrupt) {
    char c = GPS.read();
    if (GPSECHO)
      if (c) Serial.print(c);
  }
  
  if (GPS.newNMEAreceived()) {
    if (!GPS.parse(GPS.lastNMEA()))   
      return; 
  }
  if (timer > millis())  timer = millis();
  if (millis() - timer > 3000) { 
    timer = millis();
 
//------------------------IF-FIX-------------------------------------------------------------
    if (GPS.fix) {
//-------------------------DDD---------------------------------------------------------------     
    lat = GPS.latitude;
    lat = lat/100;
    latEnt = floor(lat);
    latDm = lat - latEnt;
    latDm = latDm * 1000;
    latDm = latDm/6;
    latDm = latDm/100;
    lat = latEnt + latDm;

    lon = GPS.longitude;
    lon = lon/100;
    lonEnt = floor(lon);
    lonDm = lon - lonEnt;
    lonDm = lonDm * 1000;
    lonDm = lonDm/6;
    lonDm = lonDm/100;
    lon = lonEnt + lonDm;

//---------------------------VITESSE---------------------------------------------------------------------    
    vitesseTemp = GPS.speed*1.85;
    if(vitesseMax < vitesseTemp)
      {
        vitesseMax = vitesseTemp;
      }
     
    vitesseTotale = vitesseTotale + vitesseTemp;
    vitesseMoyenne = vitesseTotale / p;
    p++;
    
    //---------------------------HEURES----------------------------------------------------------------------
    if(heuresTot1 == 0)
    {
    heures1 = GPS.hour;
    minutes1 = GPS.minute;
    secondes1 = GPS.seconds;
    heuresTot1 = heures1 + minutes1/60 + secondes1/3600;
    }
   
    heures2 = GPS.hour;
    minutes2 = GPS.minute;
    secondes2 = GPS.seconds;
    heuresTot2 = heures2 + minutes2/60 + secondes2/3600;
   
//-----------------------------------DUREE----------------------------------------------------------------
    
    temps = heuresTot2 - heuresTot1;
 
    H = floor(temps);
    m = temps - H;
    m = m * 60;
    M = floor(m);
    s = m - M;
    s = s * 60;
    S = floor(s); 
    
//----------------------------------DISTANCE--------------------------------------------------------------
    distance = vitesseMoyenne * temps;
    }
  }
} 
      
  File dataFile = SD.open("map.htm", FILE_WRITE); 
      dataFile.print("var myLatlng");dataFile.print(k); dataFile.print("= new google.maps.LatLng("); dataFile.print(lat, 6);dataFile.print(" , "); dataFile.print(lon, 6); dataFile.println(");");
      dataFile.print("var marker"); dataFile.print(k); dataFile.println("= new google.maps.Marker({");
      dataFile.print("position: myLatlng"); dataFile.print(k); dataFile.println(',');
      dataFile.println("map: map,");
      dataFile.print("title:"); dataFile.print("\""); dataFile.print(vitesseTemp); dataFile.println("\"});");
      k++;
      dataFile.close();
    }
  }
}

Library Adafruit_GPS : https://github.com/adafruit/Adafruit-GPS-Library

Please help me, i have a big project tommorrow …
Thank’s for read my post !

Of course the second program works. It just doesn't produce the results that you want. What it does and what you want you kept to yourself, though, so we can't help you.

What happens when you run this program ?

You have to take the GPS outside, or near a very large window, and wait between 20 seconds and 20 minutes for it to start up.