In: Computer Science
Answer
Here is your answer, if you have any doubt i am here to help you. please comment.
Here is your aurduino code, and circute for the above porblem. You can create it's your own Fritzing software. I created this circute and sketch in Tinkercad.
Here is the sketch and digram,
Component Required
Arduino Uno
resistors :3
LED :1
Push Button:2
Arduino sketch
/* connect two push button in digital pin, here 2 and 3.
LED connected to the digital pin 13.*/
//this variable for reading the value in push button
int p1 = 0;
int p2 = 0;
void setup()
{
//initilize the all pin.Which used for input and which used for output
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(13, OUTPUT);
}
//this function is used to wait the input from each button.
int buttonWait(int buttonPin){
int buttonState = 0;
while(1){
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
return buttonState; //when button press high it will return high, else this will execute this while infinity, similar to loop()
}
}
}
void loop()
{
p1 = buttonWait(2); //wait for the p1 value is high.
p2 = buttonWait(3); //wait for the p2 value is high
if(p1 == HIGH && p2==HIGH) //if both high then only blink led
{
digitalWrite(13, HIGH);
delay(500);
}
digitalWrite(13,LOW); //after some second it will unblink
}
Any doubt please comment, i am here to help you.
Thanks in advance