Logic Gate Implementation

Solving Approach

How do you plan to solve it?

 
 

 

 

 

Code

#define OR_LED        5
#define AND_LED       6
#define NOR_LED       7
#define NAND_LED      8

#define BUTTON1_LED   2
#define BUTTON2_LED   3

void setup() {
  // put your setup code here, to run once:
  pinMode(OR_LED, OUTPUT);
  pinMode(AND_LED, OUTPUT);
  pinMode(NOR_LED, OUTPUT);
  pinMode(NAND_LED, OUTPUT);
  pinMode(BUTTON1_LED, INPUT_PULLUP);
  pinMode(BUTTON2_LED, INPUT_PULLUP);
}

void loop() {
  // put your main code here, to run repeatedly:
  int read1 = digitalRead(BUTTON1_LED);
  int read2 = digitalRead(BUTTON2_LED);

  digitalWrite(OR_LED, read1|read2);
  digitalWrite(AND_LED, read1&read2);
  digitalWrite(NOR_LED, !(read1|read2));
  digitalWrite(NAND_LED, !(read1&read2));

}

 

 

 

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!