#define REG_SL 2
#define REG_CK 3
#define REG_DI 4

byte n[16];

void setup() {
  pinMode(REG_SL, OUTPUT);
  pinMode(REG_CK, OUTPUT);
  pinMode(REG_DI, INPUT);
  Serial.begin(9600);  
}

void loop() {
  //acquisizione porte d'ingresso
  digitalWrite(REG_SL, HIGH);
  delay(1);
  digitalWrite(REG_SL, LOW);
  delay(1);
  digitalWrite(REG_SL, HIGH);
  
  //memorizza stati
  for (int i = 0; i < 16 ; i++) {
    n[i] = digitalRead(REG_DI);
    digitalWrite(REG_CK, LOW);
    delay(1);
    digitalWrite(REG_CK, HIGH);
    delay(1);
  }
  //stampa stati
  for (int i = 0; i < 16 ; i++) {
  Serial.print(n[i], BIN);
  }
  Serial.print("\n");
    delay(50);
}
74HC165
74HC165