void setup() {
// put your setup code here, to run once:
pinMode(12, OUTPUT);
unsigned long outPin = 12;
}
void loop() {
// put your main code here, to run repeatedly:
unsigned long outPin = 12;
digitalWrite(outPin, HIGH);
delay(4000);
digitalWrite(outPin, LOW);
delay(2 * 60 * 60 * 1000);
}
I am using an uno connecting pin 12 to a transistor, which turns on a 5v relay which controls a 120v AC pump. The pump turns on initially and off after the first delay of 4 seconds. The 2nd delay is supposed to keep it off for 2 hours. However, the pump does not come back on after the 2 hours. When trouble shooting, the code works fine when set to short times. I made the 2nd delay (222*1000) and the pump turned on for 4 seconds, and off for the expected 8 seconds, then repeats. I read there are problems with the "delay" function, but the "millis" function looked to complicated for me to figure out. Any help would be appreciated.
#include "blinker.h"
// So everyone wants newbies to write blink without delay. This is good
// because delay() is bad. Well, here's the simple way to do it..
// Allocate a global blinker object.
blinker aBLinker(12,4000,2.0 * 60.0 * 60.0 * 1000.0);
void setup() {
// Fire it up.
aBLinker.setOnOff(true);
}
void loop() {
// blinker is an idler. Calling idle() once in loop lets ALL idlers run.
idle();
}
Install LC_baseTools from the library manager to compile this.