Logic Gate Implementation

Solving Approach

How do you plan to solve it?

 
 

 

 

 

Code

/*Paste your code here*/
bool input_a=1,input_b=1;
bool button_state[2]={HIGH,HIGH};
void setup() {
  // put your setup code here, to run once:
  pinMode(9, INPUT_PULLUP);
  pinMode(8, INPUT_PULLUP);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
 
}

void loop() {
  // put your main code here, to run repeatedly:
  input_a=!digitalRead(9);
  input_b=!digitalRead(8);

  if(input_a != button_state[0] || input_b != button_state[1]){

    digitalWrite(2,input_a & input_b); //or
    digitalWrite(3,input_a | input_b); //and
    digitalWrite(4,!(input_a & input_b)); //nor
    digitalWrite(5,!(input_a & input_b)); //NAND
    button_state[0]=input_a;
    button_state[1]=input_b;


  }

}


 

 

 

Output

Video

Add a video of the output (know more)

 

 

 

Upvote
Downvote

Submit Your Solution

Note: Once submitted, your solution goes public, helping others learn from your approach!