Dht11 sensor reading

(i&1)?HIGH:LOW is a bit like doing something like this:

int determineState(i) {
  int state;
  if (i&1 == true) {
    state = HIGH;
  }
  else {
    state = LOW;
  }
return state;

and then using it in the while loop like this:

while (digitalRead(dht11_pin) == determineState(i))

The ternary form makes it more compact.

1 Like