//*******************************************************
//  FlowMeter
//*******************************************************
void setupFlowMeter() {
  pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
  attachInterrupt(0, pulseCounter, RISING); //and the interrupt is attached
  loopTime = millis();
  sei();  //enable interupts
}
void pulseCounter() {               //This is the function that the interupt calls 
  pulseCount++;              //This function measures the rising and falling edge of the hall effect sensors signal
} 
void checkFlow() {
    if(millis() >= (loopTime + 2000)){  
      Calc = (pulseCount * 60 / (7.5 * 2)); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour 
      Serial.print (Calc, DEC); //Prints the number calculated above
      Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line
      lcd.setCursor(18, 3);
      lcd.print(" "); //Prints the number calculated above
      //lcd.setCursor(15, 1);
      //lcd.print(millis()/1000);
      lcd.setCursor(11, 3);
      lcd.print(Calc, DEC); //Prints the number calculated above
      lcd.print (" L/h "); //Prints "L/hour" a  
      //lcd.print(pulseCount);
      //lcd.print ("    "); //Prints "L/hour" a  
      pulseCount = 0;
      loopTime = millis();;  // Updates loopTime
    }
}
