my intention in code below have loop through array of int values represent minutes in fan should on. if finds value matches now.minute, if turns fan on, else, fan turned off. however, getting relay fan flicking on , off rapidly. not sure have gone wrong?
i feel there should way loop exit loop if fan meant on.
any hints on try appreciated.
i feel there should way loop exit loop if fan meant on.
any hints on try appreciated.
code: [select]
//fan timer control
if (light1state_on || light2state_on) { // if lights on
(int = 0; < (sizeof(fantimeon_minute) / sizeof(int)) - 1; i++) { // check see if fan should on checking minute array
if (now.minute() == fantimeon_minute[i]) {
digitalwrite(fanpin, relay_on);
fanstate_on = 1;
serial.println("fan on, fanpin = low, fanstate_on = 1");
} else {
digitalwrite(fanpin, relay_off);
fanstate_on = 0;
serial.println("fan off, fanpin = high, fanstate_on = 0");
}
}
}
Arduino Forum > Using Arduino > Programming Questions > First attempt at using an array with a for loop, not going as planned
arduino
Comments
Post a Comment