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.
Float sensor time delay
Re: Float sensor time delay
Yeah, you've got it a little wrong... but good try... let's go through each line
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.
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.
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:
otherwise we will enable the ATO function:
Code: Select all
static time_t LastATO=millis();
Code: Select all
if (!ReefAngel.LowATO.IsActive()) LastATO=millis();
Code: Select all
if (millis()-LastATO<5000 && millis()-LastATO>100)
Code: Select all
ReefAngel.Relay.Off(Port1);
Code: Select all
else
ReefAngel.SingleATO(true,Port1,10,0);
-
- Posts: 471
- Joined: Sat Jan 14, 2012 2:08 pm
- Location: Montgomery Village, MD
Re: Float sensor time delay
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.
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.
-
- Posts: 14
- Joined: Sat Aug 24, 2013 10:12 pm
- Location: Arizona
- Contact:
Re: Float sensor time delay
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