
TL;DR: In this project we simulate a Full Adder circuit using Arduino, three slide switches, XOR gates, AND gates, OR gate, and two LEDs in Ayantrik Lab. The switches act as inputs, logic gates calculate Sum and Carry, and LEDs display the result of binary addition with carry input.
The Problem / Why This Matters
Digital systems perform arithmetic using special circuits called Adders.
In real processors, addition is done using Full Adders, not half adders, because numbers are added bit-by-bit with carry from the previous stage.
Full adders are used in:
- CPUs
- Microcontrollers
- ALU (Arithmetic Logic Unit)
- Digital calculators
- Embedded systems
A Full Adder can add:
- Input A
- Input B
- Carry Input (Cin)
and produces:
- Sum
- Carry Output (Cout)
In this tutorial, we simulate the Full Adder using Ayantrik Lab, so we can understand how real digital addition works. Try it here
Basic Theory of Full Adder
A Full Adder adds three binary inputs.
Inputs:
- A
- B
- Cin (Carry input)
Outputs:
- Sum (S)
- Carry (Cout)
Full Adder uses:
- XOR gates
- AND gates
- OR gate
Boolean Expressions
S = A ⊕ B ⊕ CinCout = (A · B) + (Cin · (A ⊕ B))
Explanation:
- XOR → calculates Sum
- AND → generates carry parts
- OR → combines carry outputs
Truth Table of Full Adder
| A | B | Cin | Sum | Cout |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
In this project:
- Switch 1 → A
- Switch 2 → B
- Switch 3 → Cin
- Blue LED → Sum
- Red LED → Carry
Prerequisites
Components used:
- Arduino Uno
- 3 Slide Switches
- 2 XOR Gates
- 2 AND Gates
- 1 OR Gate
- 2 LEDs
All available in Ayantrik Lab component library.
Steps to Create the Project in Ayantrik Lab
1. Open New Project
Open Ayantrik Lab → Create new project.
Create New Project
2. Add Components
Click Add Components.
Toolbar
Add:
- Arduino Uno
- 3 Slide Switches
- XOR Gate ×2
- AND Gate ×2
- OR Gate
- 2 LEDs
Arrange properly in the canvas.
3. Make Connections
Full Adder Connection
Switch Inputs
Switch 1
- Right → 5V
- COM → D2
Switch 2
- Right → 5V
- COM → D3
Switch 3
- Right → 5V
- COM → D4
Arduino to Gates
- D13 → A
- D12 → B
- D11 → Cin
Send signals to XOR and AND gates.
Gate Logic
First XOR → A ⊕ B Second XOR → Sum
First AND → A·B Second AND → Cin·(A⊕B) OR → Carry
Output LEDs
Sum → Blue LED Carry → Red LED
LED cathodes → GND
Code
cppconst int swt1 = 2; const int swt2 = 3; const int swt3 = 4; const int input1 = 12; const int input2 = 13; const int input3 = 11; int swt1State = 0; int swt2State = 0; int swt3State = 0; void setup() { pinMode(input1, OUTPUT); pinMode(input2, OUTPUT); pinMode(input3, OUTPUT); pinMode(swt1, INPUT); pinMode(swt2, INPUT); pinMode(swt3, INPUT); } void loop() { swt1State = digitalRead(swt1); swt2State = digitalRead(swt2); swt3State = digitalRead(swt3); digitalWrite(input1, swt1State); digitalWrite(input2, swt2State); digitalWrite(input3, swt3State); }
Click Run to simulate.
Expected Behavior
| A | B | Cin | Sum | Carry |
|---|---|---|---|---|
| 0 | 0 | 0 | OFF | OFF |
| 0 | 0 | 1 | ON | OFF |
| 0 | 1 | 0 | ON | OFF |
| 0 | 1 | 1 | OFF | ON |
| 1 | 0 | 0 | ON | OFF |
| 1 | 0 | 1 | OFF | ON |
| 1 | 1 | 0 | OFF | ON |
| 1 | 1 | 1 | ON | ON |
This confirms correct Full Adder operation.
Built-in Debugging in Ayantrik Lab
Ayantrik Lab has a built-in debugger that checks:
- Wrong wiring
- Missing power
- Incorrect pins
- Code errors
Debugging
This makes learning digital logic easier.
Conclusion
In this tutorial, we simulated a Full Adder using Arduino in Ayantrik Lab.
You learned:
- Binary addition with carry
- Difference between Half Adder and Full Adder
- XOR, AND, OR combination
- Sum and Carry generation
Full adders are used in:
- ALU
- CPU
- Digital processors
- Multi-bit adders
Next try:
- 4-bit Adder
- Subtractor
- Multiplexer
- Decoder
- Flip-Flops
Happy learning with Ayantrik Lab !

