You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Great! Glad you got it sorted! You can also use setWatch if you want a function to be called when the pin changes state.

    Only think to watch out for is that if the door is normally closed (and so the contacts are normally closed) then pullup will be wasting some power (as it's like a 40k resistor is across the battery all the time) so your battery may not last too long.

    You could use pinMode(...pullup);digitalRead();pinMode("input") to use the pullup resistor only when you're reading the state of the door, and not at other times

About

Avatar for Gordon @Gordon started