Float sensor time delay

New members questions
Post Reply
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Float sensor time delay

Post by rimai »

No, millis() is as function.
http://arduino.cc/en/Reference/millis
It returns milliseconds from when the controller was booted up.
We use it to measure time.
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Float sensor time delay

Post by lnevo »

Yeah, you've got it a little wrong... but good try... let's go through each line

Code: Select all

static time_t LastATO=millis();
This is declaring a variable called LastATO that we will store the current milliseconds counter into. This will be used in future tests to see when the last time the ATO float switch was triggered. static says that we will save this variable each time the loop() function is returned (so in answering your last question, yes this code goes inside the loop() section.

Code: Select all

if (!ReefAngel.LowATO.IsActive()) LastATO=millis(); 
This line says that if the LowATO float switch is NOT (the ! means NOT) then assign the current time (in milliseconds) to the LastATO variable.

Code: Select all

 if (millis()-LastATO<5000 && millis()-LastATO>100) 
This line is doing the comparison on the current time and the variable we put the time that the float switch was not active. If the timer is within those 2 numbers we will turn off the Relay for the ATO pump:

Code: Select all

    ReefAngel.Relay.Off(Port1);
otherwise we will enable the ATO function:

Code: Select all

  else
    ReefAngel.SingleATO(true,Port1,10,0);
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: Float sensor time delay

Post by rossbryant1956 »

thx. For all us code-snatchers out there I wish all your code was documented this way!! :?
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
smadascott
Posts: 14
Joined: Sat Aug 24, 2013 10:12 pm
Location: Arizona
Contact:

Re: Float sensor time delay

Post by smadascott »

Yes! Thank you sooo much for taking the time to explain that in detail for me! Just that little explanation helps me understand the code structure so much better! Thank you! If I lived by you I would buy you lunch! lol
Post Reply