Your code could be as simple as this
const byte codePins[] = { A0, A1, A2, A3 };
const byte PINCOUNT = sizeof(codePins) / sizeof(codePins[0]);
void setup()
{
Serial.begin(115200);
for (int p = 0; p < PINCOUNT; p++)
{
pinMode(codePins[p], INPUT_PULLUP);
}
}
void loop()
{
byte codeByte = 0;
for (int p = 0; p < PINCOUNT; p++)
{
bitWrite(codeByte, p, digitalRead(codePins[p]));
}
for (int p = 0; p < PINCOUNT; p++)
{
Serial.print(bitRead(codeByte, p));
}
Serial.println();
delay(1000);
}
Once you have the value in the codeByte variable you can test it and take appropriate action