     data += flow_rate_cc_per_min;
     
     Serial.println (data);
-    
+    	
+	attachInterrupt (0, revolution, RISING);  // re-attach interrupt handler for tachometer
     last_print_time = millis();
   }
 }
 
-void data_read(int *p)
-{
-  int i,j,PinState,tempData;
-   
-  digitalWrite(TestPin, LOW);
-  for(i=0;i<5;i++)
-  {
-  for(j=0;j<8;j++)
-  {
-    do{
-      PinState = digitalRead(ClockPin);
-    }while(PinState);
-    delayMicroseconds(100);
-    PinState = digitalRead(DataPin);
-    if(1 == PinState)
-      tempData = (tempData<<1 & 0xfe)+1;
-    else
-      tempData = (tempData<<1 & 0xfe);
-    do{
-      PinState = digitalRead(ClockPin);
-    }while(PinState != 1);
-  }
-  *p++ = tempData;
-  }
-  digitalWrite(TestPin, HIGH);
-}
-
-
+
+
+
+



//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                           6. SERIAL MONITOR
unsigned int long PRINT_DELAY = 2000; //in milliseconds
unsigned int long last_print_time = 0;
String data; 



//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                           7. SHAFT TEMPERATURE SENSOR
#define  ClockPin  6  // clock in
#define  DataPin   7  //data in  
#define  TestPin   8 //driver pin  set pin low to start deliver data
///////////////////////////////////////////////////////////////////////////////////////////////////////////// 

void setup()
{
  Serial.begin(9600);   //Enable serial at high speed 
  analogReference(EXTERNAL);
  
  // Tachometer setup
  pinMode(solenoidValvePin,OUTPUT);

  sensors.begin();
  if (!sensors.getAddress(ambientTemperature, 0)) Serial.println("Unable to find address for Device 0"); 
  if (!sensors.getAddress(casingTemperature, 1)) Serial.println("Unable to find address for Device 1"); 
  if (!sensors.getAddress(glandTemperature, 2)) Serial.println ("Unable to find address for Device 2");
  sensors.setResolution(ambientTemperature, TEMPERATURE_PRECISION);
  sensors.setResolution(casingTemperature, TEMPERATURE_PRECISION);
  sensors.setResolution(glandTemperature, TEMPERATURE_PRECISION);
  sensors.setWaitForConversion(false);      //Important undocumented feature that is only needed for "parasitic mode"
  sensors.requestTemperatures();
  delayInMillis = 750 / (1 << (3)); 
  lastTempRequest = millis(); 


  //Initialize load washer samples
  for (int i = 0; i<load_sample_window; i++){
    load1_samples[i]=0;
    load2_samples[i]=0;
  }
	
	
  //Initialize SEN0093 pins (shaft temperature)
  pinMode(DataPin,INPUT);
  pinMode(ClockPin,INPUT);
  pinMode(TestPin,OUTPUT);
  digitalWrite(TestPin, HIGH);
  delay(100);
  
} 

