Not sure how this will post but here we go:
FEEL FREE TO USE AND/OR MODIFY AS YOU DESIRE
Copy and past text below into Arduino
//*
// Designed for ESP32 other boards may not operate
// Use momentary normally open switches / Light duty switches are all that is needed.
// Each press of a button changes the relays state to "off" or "on"
// Changing GPIO pin numbers is not recommended
// Do not use a solid state relay board to switch DC
// Connect as many button panels as you wish to every GPIO pin can be connected to more than once
//Ground each switch back to the ESP. I'd do it through the van body.
// One ground is all that's required for all the switches in each panel location.
//The ESP must be grounded to the van body
// Buttons should be connected to GPIO pins listed below
const int ButtonOne = 27; //wire color: Orange
const int ButtonTwo = 1; //Wire Color: Orange White
const int ButtonThree = 3; //Wire Color: Blue
const int ButtonFour = 5; //Wire Color: Blue / White
const int ButtonFive = 13; //Wire Color: Green
const int ButtonSix = 14; //Wire Color: Green / White
const int ButtonSeven = 23; //Wire Color: Brown
const int ButtonEight = 26; //Wire Color: Brown / White
// Relays should be connected to GPIO pin listed below
const int RelayOne = 2;
const int RelayTwo = 4;
const int RelayThree = 12;
const int RelayFour = 16;
const int RelayFive = 17;
const int RelaySix = 18;
const int RelaySeven = 19;
const int RelayEight = 25;
int ButtonOneState = 0;
int ButtonTwoState = 0;
int ButtonThreeState = 0;
int ButtonFourState = 0;
int ButtonFiveState = 0;
int ButtonSixState = 0;
int ButtonSevenState = 0;
int ButtonEightState = 0;
int LastButtonOneState = 0;
int LastButtonTwoState = 0;
int LastButtonThreeState = 0;
int LastButtonFourState = 0;
int LastButtonFiveState = 0;
int LastButtonSixState = 0;
int LastButtonSevenState = 0;
int LastButtonEightState = 0;
int ButtonOnePushCounter = 0;
int ButtonTwoPushCounter = 0;
int ButtonThreePushCounter = 0;
int ButtonFourPushCounter = 0;
int ButtonFivePushCounter = 0;
int ButtonSixPushCounter = 0;
int ButtonSevenPushCounter = 0;
int ButtonEightPushCounter = 0;
int DeBounceTime = 20; // used to de-bounce the pushbuttons
void setup() {
pinMode(ButtonOne, INPUT_PULLUP); // sets pins as input pullups
pinMode(ButtonTwo, INPUT_PULLUP);
pinMode(ButtonThree, INPUT_PULLUP);
pinMode(ButtonFour, INPUT_PULLUP);
pinMode(ButtonFive, INPUT_PULLUP);
pinMode(ButtonSix, INPUT_PULLUP);
pinMode(ButtonSeven, INPUT_PULLUP);
pinMode(ButtonEight, INPUT_PULLUP);
pinMode(RelayOne, OUTPUT); // sets relay pins as outputs
pinMode(RelayTwo, OUTPUT);
pinMode(RelayThree, OUTPUT);
pinMode(RelayFour, OUTPUT);
pinMode(RelayFive, OUTPUT);
pinMode(RelaySix, OUTPUT);
pinMode(RelaySeven, OUTPUT);
pinMode(RelayEight, OUTPUT);
digitalWrite (RelayOne, LOW); // sets each relay to off when ESP boots
digitalWrite (RelayTwo, LOW);
digitalWrite (RelayThree, LOW);
digitalWrite (RelayFour, LOW);
digitalWrite (RelayFive, LOW);
digitalWrite (RelaySix, LOW);
digitalWrite (RelaySeven, LOW);
digitalWrite (RelayEight, LOW);
delay(1000); //A little time for thinking
}
void loop() {
ButtonOneState = digitalRead(ButtonOne); // reads state of button
if (ButtonOneState != LastButtonOneState) {
if (ButtonOneState == HIGH) {
ButtonOnePushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonOneState = ButtonOneState;
if (ButtonOnePushCounter % 2 == 0) {
digitalWrite(RelayOne, HIGH);
} else {
digitalWrite(RelayOne, LOW);
}
ButtonTwoState = digitalRead(ButtonTwo);
if (ButtonTwoState != LastButtonTwoState) {
if (ButtonTwoState == HIGH) {
ButtonTwoPushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonTwoState = ButtonTwoState;
if (ButtonTwoPushCounter % 2 == 0) {
digitalWrite(RelayTwo, HIGH);
} else {
digitalWrite(RelayTwo, LOW);
}
ButtonThreeState = digitalRead(ButtonThree);
if (ButtonThreeState != LastButtonThreeState) {
if (ButtonThreeState == HIGH) {
ButtonThreePushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonThreeState = ButtonThreeState;
if (ButtonThreePushCounter % 2 == 0) {
digitalWrite(RelayThree, HIGH);
} else {
digitalWrite(RelayThree, LOW);
}
ButtonFourState = digitalRead(ButtonFour);
if (ButtonFourState != LastButtonFourState) {
if (ButtonFourState == HIGH) {
ButtonFourPushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonFourState = ButtonFourState;
if (ButtonFourPushCounter % 2 == 0) {
digitalWrite(RelayFour, HIGH);
} else {
digitalWrite(RelayFour, LOW);
}
ButtonFiveState = digitalRead(ButtonFive);
if (ButtonFiveState != LastButtonFiveState) {
if (ButtonFiveState == HIGH) {
ButtonFivePushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonFiveState = ButtonFiveState;
if (ButtonFivePushCounter % 2 == 0) {
digitalWrite(RelayFive, HIGH);
} else {
digitalWrite(RelayFive, LOW);
}
ButtonSixState = digitalRead(ButtonSix);
if (ButtonSixState != LastButtonSixState) {
if (ButtonSixState == HIGH) {
ButtonSixPushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonSixState = ButtonSixState;
if (ButtonSixPushCounter % 2 == 0) {
digitalWrite(RelaySix, HIGH);
} else {
digitalWrite(RelaySix, LOW);
}
ButtonSevenState = digitalRead(ButtonSeven);
if (ButtonSevenState != LastButtonSevenState) {
if (ButtonSevenState == HIGH) {
ButtonSevenPushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonSevenState = ButtonSevenState;
if (ButtonSevenPushCounter % 2 == 0) {
digitalWrite(RelaySeven, HIGH);
} else {
digitalWrite(RelaySeven, LOW);
}
ButtonEightState = digitalRead(ButtonEight);
if (ButtonEightState != LastButtonEightState) {
if (ButtonEightState == HIGH) {
ButtonEightPushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonEightState = ButtonEightState;
if (ButtonEightPushCounter % 2 == 0) {
digitalWrite(RelayEight, HIGH);
} else {
digitalWrite(RelayEight, LOW);
}
}
FEEL FREE TO USE AND/OR MODIFY AS YOU DESIRE
Copy and past text below into Arduino
//*
// Designed for ESP32 other boards may not operate
// Use momentary normally open switches / Light duty switches are all that is needed.
// Each press of a button changes the relays state to "off" or "on"
// Changing GPIO pin numbers is not recommended
// Do not use a solid state relay board to switch DC
// Connect as many button panels as you wish to every GPIO pin can be connected to more than once
//Ground each switch back to the ESP. I'd do it through the van body.
// One ground is all that's required for all the switches in each panel location.
//The ESP must be grounded to the van body
// Buttons should be connected to GPIO pins listed below
const int ButtonOne = 27; //wire color: Orange
const int ButtonTwo = 1; //Wire Color: Orange White
const int ButtonThree = 3; //Wire Color: Blue
const int ButtonFour = 5; //Wire Color: Blue / White
const int ButtonFive = 13; //Wire Color: Green
const int ButtonSix = 14; //Wire Color: Green / White
const int ButtonSeven = 23; //Wire Color: Brown
const int ButtonEight = 26; //Wire Color: Brown / White
// Relays should be connected to GPIO pin listed below
const int RelayOne = 2;
const int RelayTwo = 4;
const int RelayThree = 12;
const int RelayFour = 16;
const int RelayFive = 17;
const int RelaySix = 18;
const int RelaySeven = 19;
const int RelayEight = 25;
int ButtonOneState = 0;
int ButtonTwoState = 0;
int ButtonThreeState = 0;
int ButtonFourState = 0;
int ButtonFiveState = 0;
int ButtonSixState = 0;
int ButtonSevenState = 0;
int ButtonEightState = 0;
int LastButtonOneState = 0;
int LastButtonTwoState = 0;
int LastButtonThreeState = 0;
int LastButtonFourState = 0;
int LastButtonFiveState = 0;
int LastButtonSixState = 0;
int LastButtonSevenState = 0;
int LastButtonEightState = 0;
int ButtonOnePushCounter = 0;
int ButtonTwoPushCounter = 0;
int ButtonThreePushCounter = 0;
int ButtonFourPushCounter = 0;
int ButtonFivePushCounter = 0;
int ButtonSixPushCounter = 0;
int ButtonSevenPushCounter = 0;
int ButtonEightPushCounter = 0;
int DeBounceTime = 20; // used to de-bounce the pushbuttons
void setup() {
pinMode(ButtonOne, INPUT_PULLUP); // sets pins as input pullups
pinMode(ButtonTwo, INPUT_PULLUP);
pinMode(ButtonThree, INPUT_PULLUP);
pinMode(ButtonFour, INPUT_PULLUP);
pinMode(ButtonFive, INPUT_PULLUP);
pinMode(ButtonSix, INPUT_PULLUP);
pinMode(ButtonSeven, INPUT_PULLUP);
pinMode(ButtonEight, INPUT_PULLUP);
pinMode(RelayOne, OUTPUT); // sets relay pins as outputs
pinMode(RelayTwo, OUTPUT);
pinMode(RelayThree, OUTPUT);
pinMode(RelayFour, OUTPUT);
pinMode(RelayFive, OUTPUT);
pinMode(RelaySix, OUTPUT);
pinMode(RelaySeven, OUTPUT);
pinMode(RelayEight, OUTPUT);
digitalWrite (RelayOne, LOW); // sets each relay to off when ESP boots
digitalWrite (RelayTwo, LOW);
digitalWrite (RelayThree, LOW);
digitalWrite (RelayFour, LOW);
digitalWrite (RelayFive, LOW);
digitalWrite (RelaySix, LOW);
digitalWrite (RelaySeven, LOW);
digitalWrite (RelayEight, LOW);
delay(1000); //A little time for thinking
}
void loop() {
ButtonOneState = digitalRead(ButtonOne); // reads state of button
if (ButtonOneState != LastButtonOneState) {
if (ButtonOneState == HIGH) {
ButtonOnePushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonOneState = ButtonOneState;
if (ButtonOnePushCounter % 2 == 0) {
digitalWrite(RelayOne, HIGH);
} else {
digitalWrite(RelayOne, LOW);
}
ButtonTwoState = digitalRead(ButtonTwo);
if (ButtonTwoState != LastButtonTwoState) {
if (ButtonTwoState == HIGH) {
ButtonTwoPushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonTwoState = ButtonTwoState;
if (ButtonTwoPushCounter % 2 == 0) {
digitalWrite(RelayTwo, HIGH);
} else {
digitalWrite(RelayTwo, LOW);
}
ButtonThreeState = digitalRead(ButtonThree);
if (ButtonThreeState != LastButtonThreeState) {
if (ButtonThreeState == HIGH) {
ButtonThreePushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonThreeState = ButtonThreeState;
if (ButtonThreePushCounter % 2 == 0) {
digitalWrite(RelayThree, HIGH);
} else {
digitalWrite(RelayThree, LOW);
}
ButtonFourState = digitalRead(ButtonFour);
if (ButtonFourState != LastButtonFourState) {
if (ButtonFourState == HIGH) {
ButtonFourPushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonFourState = ButtonFourState;
if (ButtonFourPushCounter % 2 == 0) {
digitalWrite(RelayFour, HIGH);
} else {
digitalWrite(RelayFour, LOW);
}
ButtonFiveState = digitalRead(ButtonFive);
if (ButtonFiveState != LastButtonFiveState) {
if (ButtonFiveState == HIGH) {
ButtonFivePushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonFiveState = ButtonFiveState;
if (ButtonFivePushCounter % 2 == 0) {
digitalWrite(RelayFive, HIGH);
} else {
digitalWrite(RelayFive, LOW);
}
ButtonSixState = digitalRead(ButtonSix);
if (ButtonSixState != LastButtonSixState) {
if (ButtonSixState == HIGH) {
ButtonSixPushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonSixState = ButtonSixState;
if (ButtonSixPushCounter % 2 == 0) {
digitalWrite(RelaySix, HIGH);
} else {
digitalWrite(RelaySix, LOW);
}
ButtonSevenState = digitalRead(ButtonSeven);
if (ButtonSevenState != LastButtonSevenState) {
if (ButtonSevenState == HIGH) {
ButtonSevenPushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonSevenState = ButtonSevenState;
if (ButtonSevenPushCounter % 2 == 0) {
digitalWrite(RelaySeven, HIGH);
} else {
digitalWrite(RelaySeven, LOW);
}
ButtonEightState = digitalRead(ButtonEight);
if (ButtonEightState != LastButtonEightState) {
if (ButtonEightState == HIGH) {
ButtonEightPushCounter++;
}
else {}
}
delay (DeBounceTime);
LastButtonEightState = ButtonEightState;
if (ButtonEightPushCounter % 2 == 0) {
digitalWrite(RelayEight, HIGH);
} else {
digitalWrite(RelayEight, LOW);
}
}