     Serial.println(ontvangenData);
     unsigned int number = hex2int(inData);
     Serial.print(F("Onvangen data in binair: "));
-    print_binary(number,16);
+    print_binary(number, 16);
     Serial.println(F("------------------------------------------"));
     double timeOne = micros();
     verwerkInput(number);
     double timeTwo = micros();
-    double duration = timeTwo - timeOne;   
+    double duration = timeTwo - timeOne;
     printStatusPorts();
-    readStatusPorts();
+    readStatusOutputPorts();
     Serial.print(F("Tijd nodig om ALLE uitgangen te updaten[Microseconden]: "));
-    Serial.println(duration); 
+    Serial.println(duration);
     Serial.println(F("__________________________________________"));
     endMessage = false;
     beginMessage = false;
-    x = 0;    
+    x = 0;
     memset(inData, 0, sizeof(inData));
   }
+
+  leesStatusIngangen();
 }
 
 //Deze functie is enkel voor het printen van binaire waarden.
 //voorbeeld: 0000_1111_0000_0000
 void print_binary(int v, int num_places)
 {
-    int mask=0, n;
-    for (n=1; n<=num_places; n++)
+  int mask = 0, n;
+  for (n = 1; n <= num_places; n++)
+  {
+    mask = (mask << 1) | 0x0001;
+  }
+  v = v & mask;  // truncate v to specified number of places
+  while (num_places)
+  {
+    if (v & (0x0001 << num_places - 1))
     {
-        mask = (mask << 1) | 0x0001;
-    }
-    v = v & mask;  // truncate v to specified number of places
-    while(num_places)
+      Serial.print("1");
+    }
+    else
     {
-        if (v & (0x0001 << num_places-1))
-        {
-             Serial.print("1");
-        }
-        else
-        {
-             Serial.print("0");
-        }
-        --num_places;
-        if(((num_places%4) == 0) && (num_places != 0))
-        {
-            Serial.print("_");
-        }
-    }
-    Serial.println("");
+      Serial.print("0");
+    }
+    --num_places;
+    if (((num_places % 4) == 0) && (num_places != 0))
+    {
+      Serial.print("_");
+    }
+  }
+  Serial.println("");
 }
 
 //Omvormen van string naar HEX
 unsigned int hex2int(char *hex) {
-    unsigned int val = 0;
-    while (*hex) {
-        // get current character then increment
-        uint8_t byte = *hex++; 
-        // transform hex character to the 4bit equivalent number, using the ascii table indexes
-        if (byte >= '0' && byte <= '9') byte = byte - '0';
-        else if (byte >= 'a' && byte <='f') byte = byte - 'a' + 10;
-        else if (byte >= 'A' && byte <='F') byte = byte - 'A' + 10;    
-        // shift 4 to make space for new digit, and add the 4 bits of the new digit 
-        val = (val << 4) | (byte & 0xF);
-    }
-    return val;
+  unsigned int val = 0;
+  while (*hex) {
+    // get current character then increment
+    uint8_t byte = *hex++;
+    // transform hex character to the 4bit equivalent number, using the ascii table indexes
+    if (byte >= '0' && byte <= '9') byte = byte - '0';
+    else if (byte >= 'a' && byte <= 'f') byte = byte - 'a' + 10;
+    else if (byte >= 'A' && byte <= 'F') byte = byte - 'A' + 10;
+    // shift 4 to make space for new digit, and add the 4 bits of the new digit
+    val = (val << 4) | (byte & 0xF);
+  }
+  return val;
 }
 
 void verwerkInput(int input) {

#define USEDPINS_PORTB 0xE0 //b1110 0000
#define USEDPINS_PORTD 0x0C //b0000 1100
#define USEDPINS_PORTE 0x38 //b0011 1000
#define USEDPINS_PORTH 0x7B //b0111 1011
#define USEDPINS_PORTJ 0x03 //b0000 0011

//Dit ter info
/*#define INPUTMASK_PORTB 0xE000
  #define INPUTMASK_PORTD 0x0003
  #define INPUTMASK_PORTE 0x01C0
  #define INPUTMASK_PORTH 0x1E0C
  #define INPUTMASK_PORTJ 0x0030*/

int INPUT_COMMAND_PORTB = 0x00;
int INPUT_COMMAND_PORTD = 0x00;

  updateRegisterX('E', PARSE_INPUT_PORTE);
  updateRegisterX('H', PARSE_INPUT_PORTH);
  updateRegisterX('J', PARSE_INPUT_PORTJ);
}

int extractBitsBetween(int lsb, int msb, int DATA) {
  return  (DATA >> lsb) & ~(~0 << (msb - lsb + 1));
}

void setRegisterDirection() {
  //Outputs, Direction Register moet 1 zijn om uitgang te zijn
  DDRB = USEDPINS_PORTB;
  DDRD = USEDPINS_PORTD;
  DDRE = USEDPINS_PORTE;
  DDRH = USEDPINS_PORTH;
  DDRJ = USEDPINS_PORTJ;

  //Inputs, Direction Register moet 0 zijn om ingang te zijn.
  DDRF = ~USEDPINS_PORTF;
  DDRL = ~USEDPINS_PORTL;
  DDRG = ~USEDPINS_PORTG;
  DDRD = ~USEDPINS_PORTD; // Deze moet eigenlijk niet omdat DDRD bij de uitgangen al werd juist gezet.

}

//Deze functie gaat een register updaten met de waarden in NEWVALUE.
