I don't know if it's just me or what but, here is my delima.
Using:
int limSwtLeft = 11;
void setup()
pinMode(limSwtLeft, INPUT_PULLUP); // PIN D11
2 pin limit switch from pin D11 to ground.
Is there a reason this code does not work, the read shows a constant low on the serial monitor. I checked with a DMM and I can make the pin go low & high. Almost all the code I have come across shows using the code as below but, it doesn't work for me.
if(digitalRead(limSwtLeft) == HIGH);
{
Serial.println(digitalRead(limSwtLeft));
Serial.println(limSwtLeft);
do_something
}
But this code does work, which is kind of like that on the digitalRead() page does work. I have to use a variable with the digitalRead.
if(digitalRead(limSwtLeft) == HIGH)
{
lsl = 1;
}
if(digitalRead(limSwtLeft) == LOW)
{
lsl = 0;
}
Serial.println(lsl);
if(lsl == 0);
{
do_something
}
The code on the digitalRead() page shows having to assign the value of the read to a variable first.
void loop() {
val = digitalRead(inPin); // read the input pin
digitalWrite(ledPin, val); // sets the LED to the button's value
}
Am I missing something? a brain maybe?
Ray