hello guys and thanks in advance,
i am in the process of setting up a small aquaponic system. what i have is a arduino nano and a sainsmart ssr board, i understand the schematics to hook the board up however, I am haveing trouble setting up the arduino to do what i would like. what i need the arduino to do is set a pin high for 2 minutes then go low for 3 then do that 3 times then go low for 45 minutes. the kicker is that while it is doing that i need it to run a analog read on a photocell and turn another pin high or low based on the photocell reading. What i did was use the blink without delay and modified it. i added a second interval so that the pin would go low for a different amount of time that it was high. but i got frusterated because this wouldnot work. so i decided to post on here for direction or if im lucky a code i can modify
thanks again guys
this is about as far as i got and you will notice i need help with the syntax too
const int pumpPin = 13;
int pumpState = LOW;
long previousMillis = 0;
long interval1 = 12000;
long interval2 = 18000;
long interval3 = 27000;
void setup() {
pinMode(pumpPin, OUTPUT);
}
void loop()
{
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval1) {
previousMillis = currentMillis;
if (pumpState == LOW)
pumpState = HIGH;
else
pumpState = LOW;
digitalWrite(pumpPin, pumpState);
}
{
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval2) {
previousMillis = currentMillis;
if (pumpState==LOW)
pumpState = HIGH;
else
pumpState = LOW;
digitalWrite(pumpPin, pumpState);
}