const int clockEnable = 2;
const int dataIn = 3;
const int clock = 4;
const int load = 5;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("SETUP STARTED");
pinMode(clockEnable, OUTPUT);
pinMode(dataIn, INPUT);
pinMode(clock, OUTPUT);
pinMode(load, OUTPUT);
Serial.println("SETUP OVER");
}
void loop() {
// put your main code here, to run repeatedly:
byte input = getInput();
printInput(input);
}
byte getInput() {
digitalPulse(load, 5);
digitalWrite(clock, HIGH);
digitalWrite(clockEnable, LOW);
byte input = shiftIn(dataIn, clock, LSBFIRST);
digitalWrite(clockEnable, HIGH);
return input;
}
void digitalPulse(int pin, int microseconds) {
digitalWrite(pin, LOW);
delayMicroseconds(microseconds);
digitalWrite(pin, HIGH);
delayMicroseconds(microseconds);
}
void printInput(byte input) {
Serial.print("INPUT : ");
Serial.println(input, BIN);
Serial.println();
delay(200);
}