Im preatty new to this whole arduino coding thing..
I am building terrarium for chameleon which has humidity measurement and control and this is already working just fine. Now I am trying to figure out how to turn on water pump on every 1h for 3 seconds.
(chameleons do not drink from water cup so I need to spray water to leafs for short period which falls down to pump)
I have read and tried few guides, but I just can´t get my head around how to do timer which is re-occurring every X seconds for Y period of time.
Im preatty new to this whole arduino coding thing..
I am building terrarium for chameleon which has humidity measurement and control and this is already working just fine. Now I am trying to figure out how to turn on water pump on every 1h for 3 seconds.
(chameleons do not drink from water cup so I need to spray water to leafs for short period which falls down to pump)
I have read and tried few guides, but I just can´t get my head around how to do timer which is re-occurring every X seconds for Y period of time.
Could someone point me to right direction?
The BlinkWithoutDelay sketch that comes with the IDE, is a timer that re-occurs every 2 seconds for 1 second of time. Just change the numbers...
Here's an example of BlinkWithoutDelay with different on/off times. The new idea from the standard BWOD is to change the interval each time you switch from on to off and off to on.
const byte ledPin = LED_BUILTIN;// the number of the LED pin
byte ledState = LOW;
unsigned long previousMillis = 0;
unsigned long intervalOn = 1000; //use 3000 for three seconds on
unsigned long intervalOff= 5000;//use 3600000 for one hour off
unsigned long interval = intervalOff; //start off
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
if (ledState == LOW) {
ledState = HIGH;
interval = intervalOn;
} else {
ledState = LOW;
interval = intervalOff;
}
digitalWrite(ledPin, ledState);
}
}
cattledog:
Here's an example of BlinkWithoutDelay with different on/off times. The new idea from the standard BWOD is to change the interval each time you switch from on to off and off to on.
Thank you ! I looked that new BWOD and figured out that it cant work like it. I was too afraid to ask again tho