All submissions

Solving Approach

How do you plan to solve it?

 
 

 

 

 

Code

/*Paste your code here*/

const int inputA = 2;
const int inputB = 3;

const int ledOR  = 8;
const int ledAND = 9;
const int ledNOR = 10;
const int ledNAND = 11;

void setup() {
pinMode (inputA, INPUT_PULLUP);
pinMode (inputB, INPUT_PULLUP);

pinMode (ledOR, OUTPUT) ;
pinMode (ledAND, OUTPUT) ;
pinMode (ledNOR, OUTPUT) ;
pinMode (ledNAND, OUTPUT);
}

void loop() {
int A = !digitalRead(inputA); //I in
int B = !digitalRead (inputB);

// Logic gates
int andGate = A && B;
int orGate  = A || B;
int nandGate = !(A && B);
int norGate = !(A || B);

// Drive LEDS
digitalWrite (ledAND, andGate);
digitalWrite (ledOR, orGate);
digitalWrite (ledNAND, nandGate) ;
digitalWrite (ledNOR, norGate) ;
}


 

 

 

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!