Reading and using data from sd

I have been working on a data logging project where I want to be able to set a write interval easily. I thought that having a file on the SD card where the interval would be the only number in the file would be easy.

I tried modifying the code from Adafruit's SD example but can't get it to read right... Can someone shed a bit of light on how to do this?

notouch.txt had "300" on the first line, then I tried "3" and added a multipier in the code but it still doesn't work.

Here is the business portion of the code containing the only sd read call.

/*
Base only code...
 */

#include <serialGLCDlib.h>
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include "DHT.h"
#include <Wire.h>
#include "RTClib.h"
#include <SD.h>

#define DHTPIN 2 // DHT Pin
#define DHTTYPE DHT22   // DHT 22
DHT dht(DHTPIN, DHTTYPE);
RTC_DS1307 RTC;

RF24 radio(8,9); //Radio pins 3(to8),4(to9)
RF24Network network(radio);

// Our node address
uint16_t this_node;

// The message that we send is just an unsigned int, containing a sensor reading.
struct message_t
{
int temp_reading;
int humid_reading;
int voltage_reading;
int reset_reading;
  message_t(void): temp_reading(0), humid_reading(0), voltage_reading(0), reset_reading(0) {}//ADD VOLTAGE READING!!!!
};

int lcdCount = 0;
int tempf = 0;
int humidrh = 0;
int voltage = 0;
int dp = 0;
int dewP1 = 0;
int dewP2 = 0;
int dewP3 = 0;
int dewP4 = 0;
int reset = 0;
long sync = 0;
long interval = 0;

char nodereset[10] = "RS";
char nodetemp1[10] = "ND";
char humid1[10] = "ND";
char voltage1[10] = "ND";
char dp1[10] = "ND";
char nodetemp2[10] = "ND";
char humid2[10] = "ND";
char voltage2[10] = "ND";
char dp2[10] = "ND";
char nodetemp3[10] = "ND";
char humid3[10] = "ND";
char voltage3[10] = "ND";
char dp3[10] = "ND";
int nodetemp4 = 0;
int humid4 = 0;
char voltage4[10] = "ND";
char dp4[10] = "ND";
char batstat1[14] = "Odr Bat Low!";
char batstat2[14] = "Idr Bat Low!";
char batstat3[14] = "Atc Bat Low!";
char sysStat[13] = "Sys Stus:";
char sysStatc[14] = "All Ok      ";
char sysStatSD[14] = "Wrtng to SD ";

//------------------------------ SD --------------------------------------------

File myFile;

long SYNC_INTERVAL = 300000; // mills between calls to flush(), Default if not in sd file as 5min
uint32_t syncTime = 0; // time of last sync()

#define ECHO_TO_SERIAL 1 // echo data to serial port
#define WAIT_TO_START 0 // Wait for serial input in setup()

const int chipSelect = 10;

// the logging file
File logfile;

void error(char *str)
{
  Serial.print("error: ");
  Serial.println(str);
  
  // red LED indicates error
//  digitalWrite(redLEDpin, HIGH);

  while(1);
}

//-------------------------------------------------------------------------------

void setup(void)
{
  Serial.begin(115200);
  delay(5000);
  
    pinMode(53, OUTPUT);

  this_node = 0;

  //
  //DHT sensor, wire and clock
  //  

  dht.begin();
  Wire.begin();
  RTC.begin();
  
  //
  // Bring up the RF network
  //

  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 92, /*node address*/ this_node);
  
//--------------------------------- SD ---------------------------------------------

  // initialize the SD card
  Serial.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);
  
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    error("Card failed, or not present");
  }
  Serial.println("card initialized.");
  
  delay(3000);
  
 // open the file for reading:
  myFile = SD.open("notouch.txt");
    
    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      interval = myFile.read();
    }
      SYNC_INTERVAL = interval * 10000;
    	Serial.write(myFile.read());
    
    // close the file:
    myFile.close();
  
  
  // create a new file
  char filename[] = "LOGGER00.CSV";
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i/10 + '0';
    filename[7] = i%10 + '0';
    if (! SD.exists(filename)) {
      // only open a new file if it doesn't exist
      logfile = SD.open(filename, FILE_WRITE);
      break; // leave the loop!
    }
  }
  
  if (! logfile) {
    error("couldnt create file");
  }
  Serial.println(" ");
  Serial.println("Logging to:");
  Serial.println(filename);
  
  delay(3000);
  
  Serial.println(" ");
  Serial.println("Sync Time");
  sync = SYNC_INTERVAL / 1000;
  Serial.print(sync);
  Serial.print(" Seconds");
  
  delay(3000);
  
  logfile.println("datetime,Base Temp,Base Humid,Base DP,Indoor Temp,Indoor Humid,Indoor DP,Attic Temp,Attic Humid,Attic DP,Outdoor Temp,Outdoor Humid,Outdoor DP");
  
}

serialGLCD lcd; // initialisation

//------------------------------------------------------------------------------------

void loop(void)

Here is the business portion of the code containing the only sd read call.

I hardly think so.

    while (myFile.available()) {
      interval = myFile.read();
    }

What exactly is in this file? What you are doing here is reading and throwing away all but the last character in the file, which might be a carriage return or line feed.

  SYNC_INTERVAL = interval * 10000;

Then, you are pretending that the last character read from the file is an integer value, which it is, but not in the way that you think. If the file does not contain any carriage return or line feed after the value (unlikely), and contains only the single character '3', then the value in interval will be 51 (the ASCII code for '3'), which will certainly not give you the SYNC_INTERVAL you are expecting.

    	Serial.write(myFile.read());

You know that you've read the last value from the file (or the while loop would not have ended), so now you read one more. I wonder why more people don't do this?