I am reading two thumb wheels into a 74hc165 shift register and then trying to split the resulting data.
I have
//74hc165 shiftin define where my pins are
int latchPin = 8; int dataPin = 6; int clockPin = 7; int input;
void setup() {
Serial.begin(9600);
pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, INPUT);
}
void loop() {
//Pulse the latch pin, set it to 1 to collect parallel data and then wait
digitalWrite(latchPin,0); delayMicroseconds(20);
//set it to 0 to transmit data serially and then wait
digitalWrite(latchPin,1); delayMicroseconds(20);
input = shiftIn (dataPin, clockPin, MSBFIRST); digitalWrite(clockPin,1); delay (500); Serial.println (input);
If I read the input as MSBFIRST I can get one thumb wheel to read correctly in the monitor and if I read it as LSBFIRST I can get the other but only if the one I am not reading is on '0'.
How do I split the data so that I can read both thumb wheels into separate variables?
thanks,
Bob.