Hello,

a bit of a simple question, but I can't seem to find a solution-- I have a limit switch (NO) connected to pin 14 of my teensy LC:
Code:
#define S_limitSwitch  14  //  A0
. When the switch closes, it connects the pin to ground. The pull up resistor is activated:
Code:
pinMode(S_limitSwitch, INPUT_PULLUP);
. When I do
Code:
Serial.print("S_limitSwitch: ");
Serial.println(digitalRead(S_limitSwitch));
with the switch closed, I get a solid 1 (as supposed), but when it is open, the output is random 0 or 1.
I checked the switch, it works fine. Am I missing something obvious here? Could it be that the cable length of 1m from teensy to the switch causes the problem?

thanks, Philip