unsigned long zeroMillis = 0;
const long oneMillis = 1000;
void setup()
{
pinMode(5,OUTPUT);
Serial.begin(9600);
}
void loop()
{
digitalWrite(5,HIGH);
unsigned long currentMillis = millis();
if(currentMillis - zeroMillis >= oneMillis)
{
zeroMillis = currentMillis;
int light = analogRead(A0);
Serial.write("Light = ");
Serial.println(light);
}
}
So that is where I am, at the moment...
The project is a hydroponics garden, which uses an Arduino to control and measure what is happening inside the box.
Here is a list of the components I'm using:
-
Strip L.E.D's (for extra light for the plants)
-
Main powered Atomizer/Mist maker (creates fog inside of a bucket)
-
Arduino
-
LDR (connected to arduino)
-
Small 5v computer fan (connected to arduino)
-
Displaytech 162A (shows Light, Humidity and Temp level)
-
Temp & Humidity sensor
-
Three Button which will be used to turn the screen on and off and a few other functions...
MY QUESTIONS IS........(DRUM ROLL)
Does anyone know of a decent timer library or a way that I can simply and effectively turn on/off the lights, atomiser and fan. Whilst also reading the light, Humidity and temperature every second.
I thought maybe I could use "delay" but I noticed that they all add up in series and so if I have 4 delays which are one second each. I instead get a delay of 4 seconds...or all the functions working after each other in four second intervals.
What I wanted was all the components/functions turning on at the same time after 4 seconds, which was silly of me to think possible.
I'm managed to get a few things to work, but I have a feeling it wont work as I develop further.
I'm attempting to turn on and off the atomiser every 4 hours for 2 hours.
Within the 2 hour periods I'm trying to turn the fan on and off in intervals of 2 minutes (2 on, 2 off).
The reason for this is that the fog doesn't move to where I want it to, unless the fan pushes the air, although the fan can sometimes "push the air" too far, which is bad. Turing it on and off is best.
This is quite long winded, I'm hoping you have some advice or are able to direct me towards an appropriate timer which would work best.
If you would like any more info please let me know, all advice is much appreciated, thanks.