void setup() {
chipName("SN74LS283"); // 4-bit binary full adder with fast carry
logicFamily(TTL);
pin(1, "S2", OUTPUT);
pin(2, "B2");
pin(3, "A2");
pin(4, "S1", OUTPUT);
pin(5, "A1");
pin(6, "B1");
pin(7, "C0");
pin(8, "GND", GROUND);
pin(9, "C4", OUTPUT);
pin(10, "S4", OUTPUT);
pin(11, "B4");
pin(12, "A4");
pin(13, "S3", OUTPUT);
pin(14, "A3");
pin(15, "B3");
pin(16, "VCC", POWER);
}
void loop() {
// Read the inputs A and B (4 bits each) from the addressable pins
int a = digitalReadNibble(5, 3, 14, 12);
int b = digitalReadNibble(6, 2, 15, 11);
// Perform the addition of A, B, and the carry input C0 (from pin 7)
int s = a + b + (digitalRead(7) ? 1 : 0);
digitalWriteNibble(4, 1, 13, 10, s);
// Set the carry output (C4) based on the carry bit (bit 4 of the sum)
digitalWrite(9, (s & 0x10) != 0);
}