Half Adder Interpretation in Ayantrik Lab

@VijayashekarCMarch 20, 20264 Min Read

Half Adder Interpretation in Ayantrik Lab

TL;DR: In this project we simulate a Half Adder circuit using Arduino, two slide switches, XOR gate, AND gate, and two LEDs in Ayantrik Lab. The switches act as inputs, XOR produces the Sum, AND produces the Carry, and the LEDs show the result of binary addition.


The Problem / Why This Matters

Digital electronics is built using logic gates, and arithmetic operations inside computers are done using special circuits called Adders.

Adders are used in:

  • Computers
  • Microprocessors
  • Calculators
  • Digital systems
  • Embedded devices

Before learning full adders and ALU design, we must understand the Half Adder, which is the simplest binary addition circuit.

A Half Adder adds two binary inputs and produces:

  • Sum
  • Carry

In this tutorial, we simulate a Half Adder using Ayantrik Lab, so we can understand how binary addition works without building the circuit physically.

Try it here


Basic Theory of Half Adder

A Half Adder is a digital circuit that adds two binary digits.

Inputs:

  • A
  • B

Outputs:

  • Sum (S)
  • Carry (C)

Half adder uses:

  • XOR gate → Sum
  • AND gate → Carry

Boolean Expressions

  • S = A ⊕ B

  • C = A · B

Where

  • XOR gives Sum
  • AND gives Carry

Truth Table of Half Adder

ABSum (S)Carry (C)
0000
0110
1010
1101

Explanation:

  • Different inputs → Sum = 1
  • Both HIGH → Carry = 1

In this project:

  • Slide Switch 1 → Input A
  • Slide Switch 2 → Input B
  • XOR Gate → Sum
  • AND Gate → Carry
  • Blue LED → Sum
  • Red LED → Carry

Prerequisites

Components used in this project:

  • Arduino Uno
  • 2 Slide Switches
  • XOR Gate
  • AND Gate
  • 2 LEDs

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
  • AND Gate
  • 2 LEDs

Arrange them properly on the canvas.


3. Make the Circuit Connections

Half Adder connectionHalf Adder connection

Slide Switch Connections

Switch 1:

  • Right → 5V
  • COM → D2

Switch 2:

  • Right → 5V
  • COM → D3

These switches act as inputs.


Arduino to Gates

  • D13 → XOR Input A

  • D12 → XOR Input B

  • D13 → AND Input A

  • D12 → AND Input B

Arduino sends HIGH / LOW to both gates.


Gate Outputs to LEDs

XOR Output → Blue LED (Sum)

AND Output → Red LED (Carry)

LED cathodes → GND


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); } }

Click Run to start simulation.


Expected Behavior

ABSum LEDCarry LED
00OFFOFF
01ONOFF
10ONOFF
11OFFON

This confirms correct Half Adder operation.


Built-in Debugging in Ayantrik Lab

Ayantrik Lab has a built-in debugging feature that checks:

  • Circuit connections
  • Pin mapping
  • Missing power
  • Code errors

Built-in debugging toolBuilt-in debugging tool

This makes it easy to learn digital electronics without hardware mistakes.


Conclusion

In this tutorial, we simulated a Half Adder using Arduino in Ayantrik Lab.

You learned:

  • Binary addition basics
  • XOR for Sum
  • AND for Carry
  • Truth table of Half Adder
  • How adders work in digital circuits

Half adders are used in:

  • Full adders
  • ALU circuits
  • CPUs
  • Digital processors

Next you can try:

  • Full Adder
  • Subtractor
  • Multiplexer
  • Decoder
  • Flip-Flops

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