# Programming a hold button using multiple inputs

I am trying to code a set of three lights triggered by a pair of switches. My current code, attached below, triggers a light when each switch is triggered and then a third when both are triggered together.

I am looking to change the code in order to cause the third light to turn on when both switches are held together for one second. I tried using a delay function but was not able to get it to work properly.

What term do I need to add or change in order to get the desired result?

int swt1 = 0;
int swt2 = 1;
int led1 = 10;
int led2 = 11;
int led3 = 12;

void setup()
{
pinMode(0, INPUT);
pinMode(1, INPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
}

void loop()
{
{if(digitalRead(swt1) == 0){digitalWrite(led1, HIGH);} else{digitalWrite(led1, LOW);}}

{if(digitalRead(swt2) == 0){digitalWrite(led2, HIGH);} else{digitalWrite(led2, LOW);}}

{digitalWrite(led3, HIGH);}
else{digitalWrite(led3, LOW);}}
}

Yes.

Thank you for getting me to reword my question to be more clear. I am new to the platform and trying to learn.

I guess the term would be HIGH?

I take it when a switch is pressed there is a HIGH so if 2 switches are pressed then there will be 2 HIGHS to indicate 2 switches have been pressed at the same time. The 2 HIGHS could then be used to do the then when 2 are HIGH.

Did I guess correctly?

I'm unsure of what you mean in this case. At the moment the code works in that when both switches are triggered the third light comes on. The problem is that I can't find a way to create a hold parameter. I'd like to cause the third light to turn on after holding both switches for a second.

Hey, thanks for the restating of the issue.
not tested but presenting a possibility

``````void setup() {
// put your setup code here, to run once:

}

unsigned long qaz = millis();
int onDuration = 1000;
void loop()
{
{
//start timer to make LED's stay on when both switched are pressed.
qaz = millis();
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
}

if (  millis() - qaz) > = onDuration )
{

digitalWrite(led1, HIGH);
} else {
digitalWrite(led1, LOW);
}

digitalWrite(led2, HIGH);
} else {
digitalWrite(led2, LOW);
}