david_2018:
Haven't tested this, and getting late here, but try this and see how it works:
int inPin = A5; // switch A push
int in2Pin = A4; // switch B push
int in1bisPin = A1; // // switch A trigger (rocker)
int in2bisPin = A0; // switch B trigger (rocker)
int outPin = 7; // A output
int out2Pin = 6; // B output
int outstate1 = LOW;
int outstate2 = LOW;
int in1State;
int in2State;
int in1bisState;
int in2bisState;
int previous1 = 0;
int previous2 = 0;
unsigned long time = 1; // the last time the output pin was toggled
unsigned long debounce = 300; // the debounce time, increase if the output flickers
long pause = 1500;
void setup()
{
pinMode(inPin, INPUT);
pinMode(in2Pin, INPUT);
pinMode(in1bisPin, INPUT);
pinMode(in2bisPin, INPUT);
pinMode(outPin, OUTPUT);
pinMode(out2Pin, OUTPUT);
}
void loop()
{
in1State = digitalRead(inPin);
in2State = digitalRead(in2Pin);
in1bisState = digitalRead(in1bisPin);
in2bisState = digitalRead(in2bisPin);
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////ROCKER ACTIVITY////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
if ((in1bisState == HIGH) && (in2bisState == HIGH)) {
outstate1 = HIGH;
outstate2 = HIGH;
// digitalWrite(outPin, HIGH);
// digitalWrite(out2Pin, HIGH);
}
if ((in1bisState == HIGH) && (in2bisState == LOW)) {
outstate1 = HIGH;
outstate2 = LOW;
// digitalWrite(outPin, HIGH);
// digitalWrite(out2Pin, LOW);
}
if ((in1bisState == LOW) && (in2bisState == HIGH)) {
outstate1 = HIGH;
outstate2 = HIGH;
// digitalWrite(outPin, HIGH);
// digitalWrite(out2Pin, HIGH);
}
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////PUSH ACTIVITY////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
if (in1State == HIGH && outstate2 == LOW && previous1 == LOW && millis() - time > debounce) {
if (outstate1 == HIGH)
outstate1 = LOW;
else
outstate1 = HIGH;
time = millis();
}
if (in1State == HIGH && outstate2 == HIGH && previous1 == HIGH && millis() - time > debounce) {
if (outstate1 == HIGH)
outstate1 = HIGH;
time = millis();
}
digitalWrite(outPin, outstate1);
digitalWrite(out2Pin, outstate2);
previous1 = in1State;
previous2 = in2State;
}
in1bis sets output1 HIGH but it stays HIGH even if in1bis gets LOW.
And that's not what i want.
The way this project is intended is that you use either one of the switches. You're not intended to use both the kinds. HOWEVER i want it to be ready to be used like that. Like let's suppose i push the Switch B push (relays A and B turn on) but then i flip the SWITCH C trigger ON i want the relay C to turn ON.
I'm aware of the fact that it seems easy to be because it's in my mind, i'm trying my best to put it into words.