All submissions

Logic Gate Implementation

Solving Approach

How do you plan to solve it?

 
 

 

 

 

Code

 
int ledAND  = 4; 
int ledOR   = 5; 
int ledNAND = 6; 
int ledNOR  = 7; 
 
void setup() { 
  pinMode(A, INPUT_PULLUP);  

pinMode(B, INPUT_PULLUP); 
pinMode(ledAND, OUTPUT); 
pinMode(ledOR, OUTPUT); 
pinMode(ledNAND, OUTPUT); 
pinMode(ledNOR, OUTPUT); 
} 
void loop() { 
int a = !digitalRead(A);  
int b = !digitalRead(B); 
digitalWrite(ledOR,   a || b); 
digitalWrite(ledAND,  a && b); 
digitalWrite(ledNAND, !(a && b)); 
digitalWrite(ledNOR,  !(a || b)); 
delay(50); 
} 



 

 

 

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!