water flow sensor with LED and 12 v solenoid valve

hi there
i am connecting a water flow sensor and 12 v valve to arduino and some led's i am having problem with that ,what basically i need is how can i be able to send the signal from the sensor , bottom line is after detecting the ONE LITER /m the green LED should turn on then after detecting the TWO liters the yellow LED will turn ON and for three liter the red led will turn on and the solenoid valve will close (its open by default ) i am new to it , and now i can only read the flow rate on my lcd but i want to lit up the led's from the sensor input after a liter and also the valve , , any idea ?
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 6, 5, 4, 3);


volatile int NbTopsFan; //measuring the rising edges of the signal
int Calc;                               
int hallsensor = 2;    //The pin location of the sensor
int greenPin = 10;
int yellowPin = 18;

void rpm ()     //This is the function that the interupt calls 
{ 
NbTopsFan++;  //This function measures the rising and falling edge of the 

//hall effect sensors signal
} 
// The setup() method runs once, when the sketch starts
void setup() //
{ 
pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
Serial.begin(9600); //This is the setup function where the serial port is 
 pinMode(10, OUTPUT);        // sets the digital pin as output
pinMode(18, OUTPUT);        //sets the digital pin as output

//initialised,
attachInterrupt(0, rpm, RISING); //and the interrupt is attached
} 
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop ()    
{
NbTopsFan = 0;      //Set NbTops to 0 ready for calculations
sei();            //Enables interrupts
delay (1000);      //Wait 1 second
cli();            //Disable interrupts
Calc = (NbTopsFan /7.5 *25  / 7.5 ); //(Pulse frequency x 60) / 7.5Q, = flow rate 
digitalWrite(10, HIGH);
delay (25000);// as rough calculation i took 25 s = one liter but i dont want it manually because the pressure will not be constant so i want to take input from sensor to count and after one litr these LED blink as posted on my post)
digitalWrite (18,LOW);
delay (25000);
 digitalWrite(18, HIGH);
delay (25000);
digitalWrite (10,LOW);
delay (25000);


//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
//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.begin(16, 2);
 // Print a message to the LCD.
 lcd.setCursor(0, 0);
 lcd.print(Calc, DEC);
 lcd.setCursor(4, 0);
 lcd.print(" L/hour");
 lcd.setCursor(0, 1);
 lcd.print(" water flow rate ");

 

 
 
}[code]

[/code]

finals.ino (2.16 KB)

Hi, post your sketch so far, some pictures of your setup, some links to the components and a schematic diagram. Otherwise we will just be guessing!

Paul

Hi,
Go back to your post and use code tags.
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Thanks Tom..... :slight_smile:
It gives the sketch its own scrolling window and cuts down on the physical screen size of your post.