I’ve wrote up some code for lawn sprinkler automation. I’ve successfully deployed 1 system and am now working on the second. on the first system I used D0-D7 to turn on zones. On this 2nd one I’d like to try using an I2C relay to free up pins for other sensors. My question:
How do save multiple auth tokens to the same code and than select only 1 by changing a location variable in the first few lines of code?
I can’t seem to get an if statement to work above void setup.
Does this give you a picture of what I’m after?:
#define location grandpas //other locations options: Bobs, Marks, Dustins
int I2Crelay = 0;
int D0D7relay = 0;
const char *auth = "****"; //grandpas this auth code should be selected
const char *auth = "****"; //Dustins
//hardware selection this setup doesn't compile
if (location == grandpas) {I2Crelay = 1}
if (location == Dustins) {D0D7relay = 1}
void setup() {
if (I2Crelay) {
Wire.begin();
Wire.beginTransmission(ADDR);
Wire.write(0x00);
Wire.endTransmission();
}
if (D0D7relay) {
for (int i = 0; i < nValves; i++) {
pinMode(valve[i].pin, OUTPUT);
digitalWrite(valve[i].pin, HIGH);
}
}
}