You are reading a single comment by @user130485 and its replies.
Click here to read the full conversation.
-
well, it works but trying to understand how it saves power.
Just because we set variable pulledUp to true does not mean that we set pinmode to input_pullup
first line only sets the pinmode to input_pullup if pulledUp is falseif (!pulledUp) pinMode(D2,"input_pullup");
so I am trying to understand when does it actually set pinmode, if the condition when everything is ok is setting it to false...
Did you try it at all? does it work?
The idea is:
if (!pulledUp) pinMode
. This is the normal state for reading the pulses of light when the LED is not onAs it happens, because of the order of the
if (!pulledUp) pinMode
stuff we can just do what we want by setting pulledUp.