code for IR sensor to control machine

Hi , I need help in writing code , please guide how I can use Infrared sensor to control machine , like as sensor detects obstacle , machine closes down , sensor continue to give low value until reset button is press and machine is reset .

the time machine is off is add to get time for downtime.
unsigned long int milli_time; //variable to hold the time
unsigned long int milli_time1; //variable to hold the time
unsigned long int milli_time2;

float voltage; //variable to hold the voltage form A0
float voltage1; //variable to hold the voltage form A0
float voltage2;
void setup() {
Serial.begin(128000); //Fastest baudrate
Serial.println("CLEARDATA"); //This string is defined as a
// commmand for the Excel VBA
// to clear all the rows and columns
Serial.println("LABEL,CPU Clock,Vertical Bottle Time(S),Bottle Sensor ,Boxes Time(S),Boxes Sensor,Cartoner Time(S) , Cartoner Sensor");
//LABEL command creates label for
// columns in the first row with bold font
}
void loop() {
milli_time = (millis())/1000;
milli_time1 = (millis())/1000;
milli_time2 = (millis())/1000;
// voltage = 5.0 * analogRead(A4) / 1024.0;

voltage1 = 5.0 * analogRead(A0) / 1024.0;
// voltage2 = 5.0 * analogRead(A2) / 1024.0;
Serial.print("DATA,TIME,");
Serial.print(milli_time);
Serial.print(",");
Serial.print(voltage);
Serial.print(",");
Serial.print(milli_time1);
Serial.print(",");
Serial.println(voltage1);
Serial.print(",");
Serial.print(milli_time2);

Serial.print(",");
Serial.println(voltage2);

delay(1000); //Take samples every one second
}

  milli_time = (millis())/1000;
  milli_time1 = (millis())/1000;
   milli_time2 = (millis())/1000;

Why do you need three copies of the same time?

  delay(1000);                    //Take samples every one second

Not with all the Serial.print()ing going on.

please guide how I can use Infrared sensor to control machine

To start with, the final code will have NO delay() calls.

The first step is to actually read the infrared sensor. The second would be to define how the value read from the sensor will be used to "control" the machine. "Control" is WAY too vague to be meaningful.

sensor continue to give low value

You can NOT make the sensor give a specific value. It will give whatever value it can. Whether you use the value, or not, is a different story.

Hi , I need help in writing code , please guide how I can use Infrared sensor to control machine , like as sensor detects obstacle , machine closes down , sensor continue to give low value until reset button is press and machine is reset .

Too much stuff in one sentence. Break it into small pieces. Figure out how an IR sensor works. It doesn't control a machine! It just reacts to infra red lights.
Stuffing everything together in your question only prevents yourself from thinking in details, details that are very simple to figure out.