     }
     return;
 }
+
+void downloadSD()
+{
+  String dataSet;
+  int bytesStored = 0;
+  int byteCount = 0;
+          
+                      //  Close and save current SD file
+  Serial.println("SD File Saved.");
+  myFile.close();
+  
+                      //  Determine how many files exist on SD card
+  boolean fileFlag = true;
+  int m=0;
+  char fileName[15];
+  while(fileFlag)
+  {
+     sprintf(fileName, "data%d.txt", m);
+     if(SD.exists(fileName))  
+     {
+       Serial.print(fileName);
+       Serial.println(" exists.");
+     }
+     else  
+     {
+       Serial.print(fileName);
+       Serial.println(" does not exist.");
+       fileFlag = false;
+     }
+     m++;
+  }
+  
+                    //  Issue prompt to GUI on which file should be read
+  Serial.println("Prompting user to select file");
+  Serial2.print("%");
+  for(int u=0; u<(m-1); u++)  Serial2.print(u);
+  Serial2.print("\r");
+                    //  Wait for response from GUI
+  while(Serial2.available() < 3);
+                    //  Read in response
+  char start_buf[10] = "";
+  Serial2.readBytes(start_buf, Serial2.available());
+  Serial.println(start_buf);
+  sprintf(fileName, "data%c.txt", start_buf[2]);
+  Serial.println(fileName);
+  
+                    //  Open selected file
+  if(SD.exists(fileName))  myFile = SD.open(fileName, FILE_READ);
+  else  
+  {
+    Serial.println("File selected does not exist. Download cancelled");
+    return;
+  }
+  
+  bytesStored = myFile.available();
+  Serial.print(bytesStored);
+  Serial.println(" bytes available on SD card.");
+  while(byteCount <= bytesStored)
+  {
+    dataSet = "";
+    for(int r=0; r<sigNum; r++)
+    {
+      String sampBuffer = "";
+      int s=0;
+      char sampChar;
+      do
+      {
+        sampChar = myFile.read();
+        byteCount++;
+        sampBuffer += String(sampChar);
+        s++;
+      }  while((!String(sampChar).equals(" ")) && (byteCount <= bytesStored));
+      dataSet += sampBuffer;
+      if(byteCount > bytesStored) break;
+    }
+    if(byteCount >  bytesStored) break;
+    
+    Serial.print("Data Set was: ");
+    Serial.println(dataSet);
+    Serial2.print(dataSet);
+    delay(100);
+  }
+  Serial2.print("\r\n");
+  Serial2.print("#\r");
+  Serial.println("Download complete.");
+  
+  createNewSDFile();
+  return;
+}
+
+void createNewSDFile()
+{
+                            //  Close current SD file and create a new one
+    Serial.println("Creating new SD File...");
+    myFile.close();
+                            //  Check existing files to determine next file name
+    boolean fileFlag = true;
+    int m=0;
+    char fileName[15];
+    while(fileFlag)
+    {
+       sprintf(fileName, "data%d.txt", m);
+       if(SD.exists(fileName))   m++;  
+       else                      fileFlag = false;
+    }
+    Serial.print("New file name is: ");
+    Serial.println(fileName);
+    myFile = SD.open(fileName, FILE_WRITE);
+    
+    return;
+}

        {
          if(SDMode)
          {
            //SD with Xbee yet to be added, but should be much the same as below
            Serial.println("SD with Xbee yet to be added, but should be much the same");
          }
          else
          {
            Serial.println("Sending data...");
            Serial2.print(currentDataSet[i]);
            Serial2.print(" ");
            if(i == (sizeof(currentDataSet)/sizeof(float) - 1)) Serial2.print("\r");

                                           //  which helps with testing transmission 
                                           //  capacity.
                                           
int dataRateDelay = 10;                  //  Sets the delay between each transmission
                                           
//================================Setup Global Variables=================================                                            
float bdata = 0.00;   //set start point on 'B' data stream
float binc = 0.20;    //set increment on 'B' data stream
File myFile;
                                            //  These are default names for data sets.
                                            //  They may be changed freely by user, or 
                                            //  program functions.
