I think I just haven't gotten to this part of the tutorial... I got the code to do most of what I want it to do, but how do I get only one to be on at a time now?
//channel one
reading1 = digitalRead(button1);
if (reading1 == HIGH && previous1 == LOW && millis() - time > debounce) {
if (state1 == HIGH)
state1 = LOW;
else
state1 = HIGH;
time = millis();
}
digitalWrite(relay1, state1);
previous1 = reading1;
//channel two
reading2 = digitalRead(button2);
if (reading2 == HIGH && previous2 == LOW && millis() - time > debounce) {
if (state2 == HIGH)
state2 = LOW;
else
state2 = HIGH;
time = millis();
}
digitalWrite(relay2, state2);
previous2 = reading2;
//channel three
reading3 = digitalRead(button3);
if (reading3 == HIGH && previous3 == LOW && millis() - time > debounce) {
if (state3 == HIGH)
state3 = LOW;
else
state3 = HIGH;
time = millis();
}
digitalWrite(relay3, state3);
previous3 = reading3;
//channel four
reading4 = digitalRead(button4);
if (reading4 == HIGH && previous4 == LOW && millis() - time > debounce) {
if (state4 == HIGH)
state4 = LOW;
else
state4 = HIGH;
time = millis();
}
digitalWrite(relay4, state4);
previous4 = reading4;
}
Thank you everybody for the help! I am sorry for not using the proper “format” for this forum earlier. I am new. I did run the code and it worked perfectly!