Hi guys
My project is simple ( but not for me)
I have an Arduino uno ,one FLUIDS / LIQUIDS FLOW SENSOR 5-15VDC 15mA and a relay board with 4 relays. only using two of the relays.
The reason for my question is as follows it keeps counting up. l/h.
I want the board to switch the relay 1 on when it detects water flow. when it no longer detects water flow the relay 1 mast stay engaged. once the water sensor detect water flow again relay 2 must switch in and relay 1 off. once it detects water flow again relay1 must switch in and relay 2 off.
here is my code:
</>
void setup() {
// put your setup code here, to run once:
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(2, INPUT);
Serial.begin(9600);
attachInterrupt(0, pulse, RISING); // Setup Interrupt
}
void loop() {
// put your main code here, to run repeatedly:
flow = .00225 * pulse_freq;
Serial.print(flow, DEC);
Serial.println("L");
delay(500);
if((flow>0.5) && (count=0)) // You might have to play with this value
{
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
count++;
}
else if(flow<2.5) // You might have to play with this value
{
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
}
else if((flow>0.5) && (count=1))
{
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
count=0;
}
}
void pulse () // Interrupt function
{
pulse_freq++;
}
</>
what am i doing wrong?



