I'm trying to read 6 digital inputs to see if their state changes.
I have digital 2 to 7 inclusive held high or low:
2 = high
3 = high
4 = low
5 = low
6 = high
7 = low
My code is very basic at the moment but I do not understand why the state of 7 is not displayed in Serial Monitor.
int val = 0;
int prevState = 0;
void setup() {
DDRD = 0x00;
Serial.begin(9600);
}
void loop(){
prevState = val;
val = PIND;
if (val != prevState) {
Serial.println(val,BIN);
}
delay(1000);
}
I see 1001111 in Serial Monitor. I realise the left most two bits are the RX and TX pins so to me are irrelevant but only 5 data bit are visible.
Why is the bit 7 missing??
Thanks for any help.