Hi!
I'm kinda new and working on this code for our school project. We are controlling a solenoid valve via a relay, and we also would like to control it based on the readings from the water flow sensor. The if else is working in that when enough pressure is applied the valve shuts off. However after that it does not loop and turn back on. Please help!
/*-----( Declare Constants and Pin Numbers )-----*/
int FlowSensor = A2;
int Relay = 7;
/*-----( Declare objects )-----*/
void setup() /****** SETUP: RUNS ONCE ******/
{
pinMode(FlowSensor, INPUT);
Serial.begin(9600);
pinMode(Relay, OUTPUT);
digitalWrite(Relay, LOW);
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
if(analogRead(FlowSensor)>10)
{
digitalWrite(Relay,HIGH);
}
else
digitalWrite(Relay,LOW);
}