XOR Gate Interpretation in Ayantrik Lab

@VijayashekarCMarch 19, 20264 Min Read

XOR Gate Interpretation in Ayantrik Lab

TL;DR: In this project we simulate the behavior of an XOR logic gate using an Arduino, two slide switches, and an LED in Ayantrik Lab. The switches act as inputs, the XOR gate processes the logic, and the LED turns ON only when the inputs are different, demonstrating the exclusive OR rule.


The Problem / Why This Matters

Digital electronics works using logic gates, which are the basic building blocks of all modern electronic systems.

Logic gates are used in:

  • Computers
  • Microcontrollers
  • Embedded systems
  • Robotics
  • Digital circuits

Before learning advanced electronics, it is important to understand how basic gates work. One of the important gates used in digital circuits is the XOR Gate.

The XOR gate is used when we need to check whether two inputs are different.

In this tutorial, we simulate the XOR gate using Ayantrik Lab, so we can understand how comparison logic works without building the circuit physically. Try it here


Basic Theory of XOR Gate

An XOR Gate means Exclusive OR.

It gives HIGH output only when the inputs are different.

  • Two inputs (A and B)
  • One output (Y)

The output becomes HIGH when only one input is HIGH.

Boolean Expression

Y = A ⊕ B

This means output is HIGH when A and B are different.


Truth Table of XOR Gate

Input AInput BOutput Y
000
011
101
110

Explanation:

  • Inputs same → Output LOW
  • Inputs different → Output HIGH

In this project:

  • Slide Switch 1 → Input A
  • Slide Switch 2 → Input B
  • XOR Gate → Logic processor
  • LED → Output indicator

Prerequisites

Components used in this project:

  • Arduino Uno
  • 2 Slide Switches
  • XOR Gate
  • LED

All components are available in Ayantrik Lab component library.


Steps to Create the Project in Ayantrik Lab

1. Open a New Project

Open Ayantrik Lab and create a new project.

Create New ProjectCreate New Project


2. Add Components

Click Add Components from the toolbar.

ToolbarToolbar

Search and drag the following components:

  • Arduino Uno
  • 2 Slide Switches
  • XOR Gate
  • LED

Arrange them properly on the canvas.


3. Make the Circuit Connections

XOR GATE  CONNECTIONSXOR GATE CONNECTIONS

Slide Switch Connections

Switch 1:

  • Right → 5V
  • COM → D2

Switch 2:

  • Right → 5V
  • COM → D3

These switches act as digital inputs.


Arduino to XOR Gate

  • D13 → XOR Gate Input A
  • D12 → XOR Gate Input B

Arduino sends HIGH / LOW signals based on switch state.


XOR Gate to LED

  • XOR Gate Output (Y) → LED Anode
  • LED Cathode → GND

LED shows the output of the XOR gate.


Code

Upload the following Arduino code.

cpp
const int swt1 = 2; const int swt2 = 3; const int input1 = 12; const int input2 = 13; int swt1State = 0; int swt2State = 0; void setup() { pinMode(input1, OUTPUT); pinMode(input2, OUTPUT); pinMode(swt1, INPUT); pinMode(swt2, INPUT); } void loop() { swt1State = digitalRead(swt1); swt2State = digitalRead(swt2); if (swt1State == HIGH) { digitalWrite(input1, HIGH); } else { digitalWrite(input1, LOW); } if (swt2State == HIGH) { digitalWrite(input2, HIGH); } else { digitalWrite(input2, LOW); } }

After writing the code, click Run from the toolbar to start the simulation.


Expected Behavior

Try different switch positions.

Switch 1Switch 2LED
OFFOFFOFF
ONOFFON
OFFONON
ONONOFF

This confirms the correct working of the XOR logic gate.


Built-in Debugging in Ayantrik Lab

Ayantrik Lab provides a built-in debugging system that helps you detect problems in both the circuit and the code.

Built-in debugging toolBuilt-in debugging tool

The debugger can find issues such as:

  • Wrong connections
  • Missing power or ground
  • Incorrect pin mapping
  • Code errors

This makes learning digital electronics easier, especially for beginners.


Conclusion

In this tutorial, we simulated an XOR Gate using Arduino in Ayantrik Lab.

You learned:

  • Basic digital logic theory
  • Truth table of XOR gate
  • Difference detection logic
  • Using switches as inputs
  • Controlling output using logic gate

XOR gate is widely used in:

  • Comparators
  • Adders
  • Digital circuits
  • Error detection systems

Try building more logic circuits like:

Happy learning with Ayantrik Lab !

Continue Reading

How to Teach Electronics Remotely — A Guide for Indian Teachers

How to Teach Electronics Remotely — A Guide for Indian Teachers

remote teaching
June 3, 20267 Min

By Nalini Vijayakumar

Remote electronics teaching doesn't mean a watered-down curriculum. Discover how Indian teachers are using browser-based virtual labs to run richer experiments, eliminate hardware failures, and assess students more rigorously — without a single physical component.

Read Article