I have problem with compilate program with SD

Hello... I have problem with the compilation of my program. I dont known if the problem is with the new arduino version 1.6.4 with its library or the code of program . The program only write something register inside the file. But when i had that compile the program its not finish. I send the program. Thanks for your help

Archivos_v3.ino (1.18 KB)

Welcome to the forum. Please learn how to post your code within code tags (</>)icon on tool bar. It makes it easier for people to look at your code and help you.

#include <SPI.h>
#include <SD.h>
#include <Console.h>

File myFile;

void setup()
{

  Serial.begin(9600);
  while (!Serial) {
    ;
  }

  Serial.print("Initializing SD card...");
  pinMode(53, OUTPUT);

  if (!SD.begin()) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
}


void loop()
{
  int Volt=random(190,240);
  int Ampe=random(0,70);

  Serial.print(" Valores de Tension= ");
  Serial.print(Volt);
  Serial.print(" Amperaje= ");
  Serial.println(Ampe);
  
  myFile = SD.open("test.txt", FILE_WRITE);
  
  GuardarDato(Volt,Ampe,myFile);
  myFile.close();
}


/************    FUNCIONES    ******************/

void GuardarDato(int Volt,int Ampe,File myFile){

  int cont=0;
   
  if (myFile) {
    Serial.print("Escribiendo en Archivo test.txt...");
    myFile.print("Registro N°");
    myFile.print(cont);
    myFile.print(" Voltaje: ");
    myFile.print(Volt);
    myFile.print(" Amperaje: ");
    myFile.println(Ampe);
    myFile.close();
    Serial.print("Se guardo registro ");
    Serial.print(Volt);
    Serial.print(" - ");
    Serial.println(Ampe);
  } else {
    Serial.println("No se pudo abrir archivo test.txt");
  }
 cont++;

}

Do you have console.h library installed? I do not have it, and your code would not compile for me until I commented out that line. It did not complete and showed no error.

With that line commented out, and some pin numbers changed for my setup, I can compile and run your program with 1.6.4 in Windows 7.

Change line 48 int cont =0 to static int cont =0 or your index will not increment.

Thanks so much,

I am having the same issue with several files. I make a change to the code and compile it only to get 1/4 of a bar and that's it. Just sits there. Go back and undo the changes and it's ok again.