All submissions

Logic Gate Implementation

Solving Approach

How do you plan to solve it?

 For inputs (12, 13) and outputs (3,4,5,6)

Fixed INPUT_PULLUP syntax and added missing semicolons

Corrected NAND/NOR logic using ! (NOT operator)

Standardized variable names (e.g., pinAND instead of pinNMD)

Removed duplicate/incorrect pinMode calls

Fixed conditional checks in digitalWrite statements

In wiring

The switches is connected between GND and pins 12/13 (internal pull-up enabled)

And the LEDs is connected each to pins 3-6 (through current-limiting resistors) to show AND/OR/NAND/NOR outputs
 

 

 

 

Code

/*Paste your code here*/

const int inputA = 12;
const int inputB = 13;
const int pinAND  = 6;
const int pinOR   = 3;
const int pinNAND = 5;
const int pinNOR  = 4;
void setup() {
 pinMode(inputA, INPUT_PULLUP);
  pinMode(inputB, INPUT_PULLUP);
   pinMode(pinAND, OUTPUT);
    pinMode(pinOR, OUTPUT);
     pinMode(pinNAND, OUTPUT);
      pinMode(pinNOR, OUTPUT);    
}
void loop() {
 bool A = (digitalRead(inputA) == LOW);
  bool B = (digitalRead(inputB) == LOW);
   digitalWrite(pinAND,  (A && B)  ? HIGH : LOW);
    digitalWrite(pinOR,   (A || B)  ? HIGH : LOW);
     digitalWrite(pinNAND, (!(A && B))? HIGH : LOW);
       digitalWrite(pinNOR,  (!(A || B))? HIGH : LOW);
}

 

 

 

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!