Water Sprinker Alarm

The "Eleven" is our Uno-equivalent Arduino-compatible board, but with a number of improvements including prototyping area, a mini-USB connector, LEDs mounted near the edge, and the D13 LED isolated using a FET. [Product page]
Post Reply
crickeys
Posts: 4
Joined: Wed Jul 23, 2014 5:06 am

Water Sprinker Alarm

Post by crickeys » Wed Jul 23, 2014 5:28 am

For a school project I am building a sprinkler alarm using the Eleven.
I am taking the magnetic pulses (Hall effect)from my watermeter via the Eleven to monitor waterflow.
I need a sketch for two alarms
1. Waterflow of more than 40mins
2. No waterflow in 12 hours

So far i have found ideas of using the delay, but Arduino states

"Using delay() has a (usually not intended) sideeffect - the Arduino does nothing for that while. To get two or more "actions" to run independent of each other, you can not use delay()." As i have two actions i need another solution.
Another idea was to use a counter ( RTC is out as i want to keep the price down).

If anyone has a sketch that would help, it would be much appreciated as i'm going nowhere fast :?:

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: Water Sprinker Alarm

Post by andrew » Wed Jul 23, 2014 10:25 pm

Don't start with looking for a sketch first, instead write an algorithm or a plan of what you want to happpen in non-technical terms. Then after a little throught it will easily translate to a sketch.

For example, if you were checking the flow yourself - how would you write a set of instructions to tell someone else how to do it?

Finally if you don't want a RTC then there's the Arduino time library:
http://playground.arduino.cc/code/time

crickeys
Posts: 4
Joined: Wed Jul 23, 2014 5:06 am

Re: Water Sprinker Alarm

Post by crickeys » Mon Jul 28, 2014 11:35 pm

Hi Johnb,
Thanks for the time library but I still couldn't find an answer.
My problem is when the water pulse is not detected, the delay function sets off the alarm after 12hrs. Now if the water comes back on during this delay I want it to reset but the delay cannot do two things at once.( ie delay and reset.).
So my question is do you know of any other timer function I could use to avoid using delay()?

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: Water Sprinker Alarm

Post by andrew » Tue Jul 29, 2014 5:27 am

You can use millis instead of delay, there's a good explanation of that here:
http://playground.arduino.cc/Code/AvoidDelay
However for longer durations you might need to go back to considering the time library or a RTC.

Post Reply