Hi there,
Can anyone help me, I'm having problems in my project. I'M sing Hall-Effect flow sensor to measure flow of liquid, so It does give me the readings on the LCD but the problem is when there is no liquid passing through the sensor, the readings go back to zero again, I want the readings to stay there until another flow pass and add on the readings displayed on LCD,Here is the the code I used:
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystallcd(12, 11, 6, 5, 4, 3);
volatileintFlowPulse; //measuring the rising edges of the signal
intCalc;
intflowsensor=2; //The pin location of the sensor
voidsetup() {
pinMode(flowsensor, INPUT); //initializes digital pin 2 as an input
Serial.begin(9600); //This is the setup function where the serial port is initialised,
attachInterrupt(0, rpm, RISING); //and the interrupt is attached
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(0, 1);
lcd.print("Flow Meter");
}
voidloop() {
FlowPulse=0; //Set NbTops to 0 ready for calculations
sei(); //Enables interrupts
delay (1000); //Wait 1 second
cli(); //Disable interrupts
Calc= (FlowPulse*60/7.5); //(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
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 2);
lcd.print(Calc,DEC); // print the Flow Rate
lcd.print(" L/hour");
}
voidrpm () //This is the function that the interupt calls
{
FlowPulse++; //This function measures the rising and falling edge of the hall effect sensors signal
}