10. Logic Gate Implementation

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

 To implement logic gates on a breadboard, we use combinations of transistors, resistors, and LEDs to simulate gate behavior. Each gate (AND, OR, NAND, XOR) is wired so that the LED lights up only when the gate's logical condition is met. Inputs are controlled via jumper wires or switches, and outputs are visualized through LED states.
 

 

 

 

Code

/*Paste your code here*/

const int inputA = 12;
const int inputB = 13;

const int pinAND  = 7;
const int pinOR   = 4;
const int pinNAND = 6;
const int pinNOR  = 5;

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)

 

 

 

Was this helpful?
Upvote
Downvote