Water Flow Sensor + Relay Shield Arduino

Hello you guyz

How can I do a code that read the water flow and blocking the water with a selenoid valve and relay shield?

I have a water flow sensor connected with a selenoid valve. When the sensor reads ~hypothetically~ 1L of water the relay cut off the connection with selenoid valve, blocking the water flow.

Can everyone help me?

*I know the hardware connections, i just need a code.

Thanks :slight_smile:


if (waterFlown > 1) digitalWrite(relayPin, LOW);

where waterFlown is a float containing the amount of water measured in litres; relayPin connects to your relay (active HIGH).