//setting the variables to the appropriate d(n) location
int F0 = 12; 
int F1 = 11;
int ENA = 10;
int A = 9;
int ENB = 8;
int B = 7;
int Cin = 6;
int INVA = 5;

int Out = 3;
int CO = 2;

//Temporary Variables
int f0;
int f1;
int ena;
int a;
int enb;
int b;
int cin;
int inva;
int out;
int co;


//4 custom operation variables to store data
int ab;
int aORb;
int notB;
int sum;


//2 custom variables to shorten the process of checking a, b, enableB, and enableA
int enableA;
int enableB;


void setup() {
  // put your setup code here, to run once:
  //setting the pins to the correct input/output parameter
  pinMode(Out, OUTPUT);
  pinMode(CO, OUTPUT);
  pinMode(F0, INPUT_PULLUP);
  pinMode(F1, INPUT_PULLUP);
  pinMode(ENA, INPUT_PULLUP);
  pinMode(A, INPUT_PULLUP);
  pinMode(ENB, INPUT_PULLUP);
  pinMode(B, INPUT_PULLUP);
  pinMode(Cin, INPUT_PULLUP);
  pinMode(INVA, INPUT_PULLUP);

}

void loop() {
  // put your main code here, to run repeatedly:
  //taking the input of the pins and assign values to the correct temporary variables
  a = digitalRead(A);
  b = digitalRead(B);
  f0 = digitalRead(F0);
  f1 = digitalRead(F1);
  ena = digitalRead(ENA);
  enb = digitalRead(ENB);
  cin = digitalRead(Cin);
  inva = digitalRead(INVA);

  //initalizing output and carry out to not produce anyting
  out = LOW;
  co = LOW;

  //shortcut variables to check that A and or B is actually initalized for use
  //allows the future code to be less messy
  //A is active if a and ena are HIGH input, Xor if inva is active
  enableA =((a & ena) ^ (inva));
  enableB =  (b & enb);

  //operation AB, only possible if f0 = low and f1 = low
  ab = (!f0 & !f1) & (enableA & enableB);


  //operation A + B, only possbile if f0 is low and f1 is high
  aORb = (f1 & !f0) & (enableA | enableB);
  
  //opperation not B, only possible if f0 is high and f1 is low
  notB = (!f1 & f0) & !enableB;

  //Sum and Carry out for one bit operation, only possible when both f1 and f0 are high
  sum = (f0 & f1) & ((enableA ^ enableB) ^ cin);
  co = (f1 & f0) & ((enableA & enableB) | (enableA & cin) | (enableB & cin));
    
  out = ab ^ aORb ^ notB ^ sum;


  digitalWrite(Out, out);
  digitalWrite(CO, co);
}
$abcdeabcde151015202530354045505560fghijfghij
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
sw1:1a
sw1:2a
sw1:3a
sw1:4a
sw1:5a
sw1:6a
sw1:7a
sw1:8a
sw1:8b
sw1:7b
sw1:6b
sw1:5b
sw1:4b
sw1:3b
sw1:2b
sw1:1b
r1:1
r1:2
r2:1
r2:2
led1:A
led1:C
led2:A
led2:C