All submissions

Logic Gate Implementation

Solving Approach

How do you plan to solve it?

 
 

 

 

 

Code

/*Paste your code here*/


#define OR_GATE_PIN 8
#define AND_GATE_PIN 9
#define NOR_GATE_PIN 10
#define NAND_GATE_PIN 11

#define INPUT_A 2
#define INPUT_B 3

bool A=0,B=0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(OR_GATE_PIN,OUTPUT);
  pinMode(AND_GATE_PIN,OUTPUT);
  pinMode(NOR_GATE_PIN,OUTPUT);
  pinMode(NAND_GATE_PIN,OUTPUT);

  pinMode(INPUT_A,INPUT_PULLUP);
  pinMode(INPUT_B,INPUT_PULLUP);
}

void loop() 
{
  A = !(digitalRead(INPUT_A));
  B = !(digitalRead(INPUT_B));


  digitalWrite(OR_GATE_PIN,(A|B));
  digitalWrite(AND_GATE_PIN,(A&B));
  digitalWrite(NOR_GATE_PIN,!(A|B));
  digitalWrite(NAND_GATE_PIN,!(A&B));

}

 

 

 

Output

Video

Add a video of the output (know more)

 

 

 

 

Submit Your Solution

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