I have done my final year grand project with arduino . My project on real-time fluid controling and measuring devices. This was so typicall and hard but finaly i have done. Below I uploaded all details about my projects you can try it. ino code is also avail there flowgauge
here is full code that
/**
* Water Flow Gauge
*
* Uses a hall-effect flow sensor to measure the rate of water flow and
* output it via the serial connection once per second. The hall-effect
* sensor connects to pin 2 and uses interrupt 0, and an LED on pin 13
* pulses with each interrupt. Two volume counters and current flow rate
* are also displayed on a 2-line by 16-character LCD module, and the
* accumulated totals are stored in non-volatile memory to allow them to
* continue incrementing after the device is reset or is power-cycled.
*
* Two counter-reset buttons are provided to reset the two accumulating
* counters. This allows one counter to be left accumulating indefinitely
* as a "total" flow volume, while the other can be reset regularly to
* provide a counter for specific events such as having a shower, running
* an irrigation system, or filling a washing machine.
*
* Copyright 2009 Jonathan Oxer <jon@oxer.com.au>
* Copyright 2009 Hugh Blemings <hugh@blemings.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. http://www.gnu.org/licenses/
*
* www.practicalarduino.com/projects/water-flow-gauge
123456789abcdef
1239.4L 8073.4L
*/
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(9, 8, 7, 6, 5, 4);
byte sensorInterrupt = 0; // 0 = pin 2; 1 = pin 3
byte sensorPin = 2;
// The hall-effect flow sensor outputs approximately 4.5 pulses per second per
// litre/minute of flow.
//float calibrationFactor = 4.5;
volatile byte pulseCount;
float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitresA;
unsigned long Litres;
unsigned long oldTime;
void setup()
{
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(" ");
// Initialize a serial connection for reporting values to the host
Serial.begin(38400);
pulseCount = 0;
flowRate = 0.0;
flowMilliLitres = 0;
totalMilliLitresA = 0;
Litres = 0.0;
oldTime = 0;
// The Hall-effect sensor is connected to pin 2 which uses interrupt 0.
// Configured to trigger on a FALLING state change (transition from HIGH
// state to LOW state)
attachInterrupt(sensorInterrupt,pulseCounter, FALLING);
}
/**
* Main program loop
*/
void loop()
{
if((millis() - oldTime) > 1000)
{
detachInterrupt(sensorInterrupt);
flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / 4.5;
oldTime = millis();
flowMilliLitres = (flowRate / 60) * 1000;
totalMilliLitresA += flowMilliLitres;
Litres += flowMilliLitres;
Serial.print(pulseCount, DEC);
Serial.print(" ");
lcd.setCursor(14,1);
lcd.print(pulseCount);
unsigned int frac;
Serial.print(int(flowRate)); // Print the integer part of the variable
Serial.print("."); // Print the decimal point
// Determine the fractional part. The 10 multiplier gives us 1 decimal place.
frac = (flowRate - int(flowRate)) * 10;
Serial.print(frac, DEC) ; // Print the fractional part of the variable
// Print the number of litres flowed in this second
Serial.print(" "); // Output separator
Serial.print(flowMilliLitres);
// Print the cumulative total of litres flowed since starting
Serial.print(" "); // Output separator
Serial.print(totalMilliLitresA);
Serial.print(" "); // Output separator
Serial.println(Litres);
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print("Flow:");
if(int(flowRate) < 10)
{
lcd.print(" ");
}
lcd.print((int)flowRate); // Print the integer part of the variable
lcd.print('.'); // Print the decimal point
lcd.print(frac, DEC) ; // Print the fractional part of the variable
lcd.print(" L/m");
//lcd.print("/min");
lcd.setCursor(0, 1);
lcd.print(int(totalMilliLitresA));
lcd.print("mL");
lcd.setCursor(8, 1);
lcd.print(Litres / 1000.0);
//lcd.print('.'); // Print the decimal point
//lcd.print(frac, DEC) ; // Print the fractional part of the variable
lcd.print("L");
// Reset the pulse counter so we can start incrementing again
pulseCount = 0;
// Enable the interrupt again now that we've finished sending output
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
}
/**
* Invoked by interrupt0 once per rotation of the hall-effect sensor. Interrupt
* handlers should be kept as small as possible so they return quickly.
*/
void pulseCounter()
{
// Increment the pulse counter
pulseCount++;
}