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
}