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
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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