Function is not working

hi

here is my code will get the sensor values from defined pins and stores in .csv file
when i try to print the values in a file through a function it is not happening can any one check out my function

#include<LiquidCrystal.h>
#include<SD.h>
#include<SPI.h>
#include <Wire.h>
#include "RTClib.h"

#define RED       6
#define GREEN     7
#define BLUE      8
#define buttonPin1 16  //Analog pin A2 Reff
#define SS        10

LiquidCrystal lcd(14, 15, 5, 4, 3, 2);       // sets the interfacing pins 14-A0(RS), 15-A1(E)
Sd2Card card; SdVolume volume; SdFile root;  // set up variables using the SD utility library functions:
File logFile;
RTC_DS1307 rtc;

void setup() {
  pinMode(RED, INPUT); pinMode(GREEN, INPUT); pinMode(BLUE, INPUT);
  pinMode(buttonPin1, INPUT_PULLUP);
  int buttonState1, buttonState2;
  Serial.begin(9600);
  Wire.begin();
  rtc.begin();
  lcd.begin(16, 2);                                                            // initializes the 16x2 LCD
  Check();
  DateTime now = rtc.now();// Checks the SDcard RTC is present or not
  String U = String(now.unixtime());
  String  Filename = Unixfile(U); Serial.print("Filename:"); Serial.print(Filename);   //  Creates the UnixTime as a Filename

  logFile = SD.open(Filename, FILE_WRITE);
  logFile.print(U); logFile.print("\n"); logFile.flush();
  logFile.print("RReffTP"); logFile.print(","); logFile.print("GReffTP"); logFile.print(","); logFile.print("BReffTP\n"); logFile.flush();

  while (1)
  {
    buttonState1 = digitalRead(buttonPin1);
    double REDAbsorption, GREENAbsorption, BLUEAbsorption;
    double tpReffR[30], tpReffG[30], tpReffB[30];
    double tpSampleR, tpSampleG, tpSampleB;

    if (buttonState1 == LOW)
    {

      for (int i = 0; i < 30; i++)
      {

        tpReffR[i] = pulseIn(RED, LOW, 10000) * 2; tpReffG[i] = pulseIn(GREEN, LOW, 10000) * 2; tpReffB[i] = pulseIn(BLUE, LOW, 10000) * 2;
        Serial.print("\ntpReffR  "); Serial.print(tpReffR[i]);
        delay(10);
      }
      delay(500);
      printfile(tpReffR, tpReffG, tpReffB, 30);
      buttonState1 == HIGH;
    }
  }

}

//**************************************************************************************************************************************************************************

void printfile(double *R, double *G, double *B, int Len)
{

  logFile.print("function testing"); logFile.flush();

  Serial.print("\n function;  ");
  for (int i = 0; i < Len; i++)
  {
    Serial.println(R[i]); logFile.flush();
  }
  Serial.print("Done.....");
}
//********************************************************************************************************************************************************************

void Check()
{
  DateTime now = rtc.now();
  if ((!SD.begin(SS)) || (!rtc.isrunning()))
  {
    lcd.setCursor(0, 0); lcd.print("Insert SDcard or"); Serial.println("Insert SDcard or");
    lcd.setCursor(0, 1); lcd.print("Check RTC       "); Serial.println("Check RTC");
    //delay(1000);
    exit (0);
  }
  else
    lcd.setCursor(0, 0); lcd.print("                "); lcd.setCursor(0, 1); lcd.print("                ");
  lcd.setCursor(0, 0); lcd.print("SDCard Present  "); lcd.setCursor(0, 1); lcd.print("RTC is Working  "); delay(1000);

}

//*******************************************************************************************************************************************************************

String Unixfile(String U)
{
  char Name[12] = {0};
  for (int i = 0; i < 7; i++)
  {
    Name[i] = U[i];
  }
  Name[7] = '.';
  for (int i = 7; i < 10; i++)
  {
    Name[i + 1] = U[i];
  }
  lcd.setCursor(0, 0); lcd.print("UTC: "); lcd.print(U); lcd.setCursor(0, 1); lcd.print("File:"); lcd.print(Name); delay(1000);
  lcd.setCursor(0, 0); lcd.print("                "); lcd.setCursor(0, 1); lcd.print("                ");
  return Name;
}
//******************************************************************************************************************************************************************

void loop()
{}

What function is not working?

What actually happens when you try the program?

What should happen?

...R

Why while(1)? Isn't that what loop() is for? Can you write a small program using just your function to test it?

printfile(tpReffR, tpReffG, tpReffB, 30);

this function is not working

i can use loop also but while(1) has a same logic na

What does "working" mean, in this context?

AWOL:
What does "working" mean, in this context?

function could not able to print the values into file

naidu003:
function could not able to print the values into file

So what does get printed into the file?

...R

Maybe the code did not manage to open the file?

You should check the result of the open operation

logFile = SD.open(Filename, FILE_WRITE);
if(logFile == NULL)
{
  Serial.println("error opening file");
  for(;;);
}

This will display the error and forever hang the program after that.

Or maybe it does not work because you never close your file? Not 100% sure about this though.

Replace the line that is not very useful (buttonState1 == HIGH;) by

logfile.close();
for(;;);

This will close the file and next hand the program forever; at least you should be able to see one set oif readings.
This will close the file and next wait forever. Did anything get written to the file?

I figured out the problem

I have not defined one sensor pin which will give me the sensor output data
so data is not available in buffer i think so , that causes problem for not logging the data into file