Editing of posts after people have discussed in several following posts them makes reading the thread very hard as they refer to something no longer there. Keep the edit feature to minor typos or suchlike.
Back to the subject: The code as I read it at this moment you declare two variables with the same content. The setup code does: Set pin to Input, Write High to pin, set pin to Output. The loop then reads the output pin. Reading an output pin "should" return the last value written...(similar case
) which is HIGH.
If we leave out the 2nd defenition, or rather change (to avoid the undefined compiler error) then the code is
Set pin to input, Write high. The code then just reads the input pin.
You claim the exact opposite is happening. Have I understood you correctly?
I tried your code on my Arduino and it works for either case. Here is my code (which I will not
edited after posting
const int FrontDoorPin = 4;
const int relay = 4; // changed to 11 .. still works
digitalWrite(FrontDoorPin, HIGH); //pull up
if (digitalRead(FrontDoorPin) == LOW)
else digitalWrite(13,LOW) ;
I even listed the assembly output and there is no "funnies" about the compiler getting confused or optimizing something away.