// Pin connections
const int dataPin = 9; // Q7 pin of 74HC165
const int loadPin = 10; // PL pin of 74HC165
const int clockPin = 13; // CP pin of 74HC165
void setup() {
pinMode(dataPin, INPUT);
pinMode(loadPin, OUTPUT);
pinMode(clockPin, OUTPUT);
// Initialize serial communication for debugging
Serial.begin(9600);
}
void loop() {
// Read parallel input states into the shift register
digitalWrite(loadPin, LOW); // Load the parallel inputs into the shift register
delayMicroseconds(5);
digitalWrite(loadPin, HIGH); // Prepare to shift the data out
delayMicroseconds(5);
// Shift the data out and read the states
byte buttonStates = shiftIn(dataPin, clockPin, MSBFIRST);
// Print the button states for debugging
Serial.print("Button states: ");
Serial.println(buttonStates, BIN);
delay(500); // Loop delay
}