Logic Gate Full Adder
ESP32 DevKit (WROOM-32)·Arduino C++·Updated Jul 27, 2026·by FluxBench TeamIncludes Lab + Schematic + PCB
The next step after the half adder: a 1-bit FULL adder built from five 74HC-style gate modules — two XORs, two ANDs and an OR — where gate outputs feed other gate inputs through a depth-3 network that the Lab solves from real voltages. The ESP32 drives A, B and carry-in from three GPIOs, reads SUM and CARRY back, and verifies all eight truth-table rows live; two LEDs show the result on the bench. Pull any wire mid-run and the chain genuinely breaks. Bundled Lab bench, schematic and routed PCB included.
sketch.ino
// Logic Gate Full Adder - five gates compute A + B + Cin
// P = A XOR B, SUM = P XOR Cin, CARRY = (A AND B) OR (P AND Cin)
#define PIN_A 25
#define PIN_B 26
#define PIN_CIN 27
#define PIN_SUM 32
#define PIN_CARRY 33
int combo = 0;
int errors = 0;
void setup() {
Serial.begin(115200);
pinMode(PIN_A, OUTPUT);
pinMode(PIN_B, OUTPUT);
pinMode(PIN_CIN, OUTPUT);
pinMode(PIN_SUM, INPUT);
pinMode(PIN_CARRY, INPUT);
Serial.println("Full adder trainer: A + B + Cin = CARRY,SUM");
Serial.println(" A B Cin | SUM CARRY");
}
void loop() {
int a = (combo >> 2) & 1;
int b = (combo >> 1) & 1;
int cin = combo & 1;
digitalWrite(PIN_A, a);
digitalWrite(PIN_B, b);
digitalWrite(PIN_CIN, cin);
delay(60); // let the gate chain settle
int sum = digitalRead(PIN_SUM);
int carry = digitalRead(PIN_CARRY);
int total = a + b + cin;
int wantSum = total & 1;
int wantCarry = (total >> 1) & 1;
Serial.print(" ");
Serial.print(a);
Serial.print(" ");
Serial.print(b);
Serial.print(" ");
Serial.print(cin);
Serial.print(" | ");
Serial.print(sum);
Serial.print(" ");
Serial.print(carry);
if (sum == wantSum && carry == wantCarry) {
Serial.println(" ok");
} else {
Serial.println(" MISMATCH");
errors++;
}
combo++;
if (combo == 8) {
if (errors == 0) {
Serial.println("All 8 rows verified - full adder works!");
} else {
Serial.println("Check your wiring - mismatches found.");
}
combo = 0;
errors = 0;
Serial.println(" A B Cin | SUM CARRY");
}
delay(1440);
}Built with FluxBench.AI — the AI workbench for embedded projects.