hwy peeps so im trying to make it so when switch 1 is "high" and Switch 2 is LOW and the button is pressed then LED == HIGH
For example,
hard to explain so i want so if one switch is on and the other is off and i press the button then the led will be on while the button is pressed
and if its the other way around switch 1 is off and switch 2 is on the led will "blip" when the button is pressed ,
sorry for the Very bad code setup im testing it in the Tinkercad circuit, what ever i do i cant seem to get it to work?
int Mswitch1 = 5;
int Tog1 = 2;
int Tog2 = 3;
int snd = 4;
unsigned long startTime = millis();
int T1 = 0;
//---------------------------------------------------------------
void setup() {
Serial.begin(9600);
// digitalWrite(switchPin, HIGH);
pinMode(Mswitch1,INPUT);
pinMode(Tog1, INPUT);
pinMode(Tog2, INPUT);
pinMode(snd, OUTPUT);
}
//-----------------------------------------------------------------
void loop() {
// ---------------------------
if (digitalRead(Tog1) == HIGH){
T1 = 1;
if (digitalRead(Tog2) == HIGH){
T1 = 2;
}
}
//-----------------------------
// ---------------------------
if (digitalRead(Tog2) == HIGH){
T1 = 2;
}
//-----------------------------
// if ((digitalRead(Mswitch1) == HIGH)){
// digitalWrite(snd, HIGH);
// Serial.println(T1 && "1");
// T1 = 0;
// digitalWrite(snd,LOW);
// }
// if ((digitalRead(Mswitch1) == HIGH) && (T1 == 1)
// ---------------------------
if ((digitalRead(Mswitch1) == HIGH) && (T1 == 1)){
digitalWrite(snd, HIGH);
T1 = 0;
//erial.println(T1 && "1");
}
// ---------------------------
if ((digitalRead(Mswitch1) == HIGH) && (T1 == 2)){
delay(1000);
while ( digitalRead(Mswitch1) == HIGH && millis() < (startTime + 100) && (T1 = 1)) {
digitalWrite(snd, HIGH);
// Serial.println(T1 && "2");
T1 = 0;
}
}
//-----------------------------
}
void callMillis(unsigned long x)
{
unsigned long presentMillis = millis();
while (millis() - presentMillis != x)
{
//============ End Void callmillis ============
}
}
//----------------------------------------------------------------