Question about Digital read

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

It's the semicolon...

 if(digitalRead(limSwtLeft) == HIGH);
 {

aarg:
It's the semicolon...

 if(digitalRead(limSwtLeft) == HIGH);

{

aarg you saved my butt again. Maybe I should cut back my hours on coding and other work LOL.

Thanks again

Ray

This is the connection view of your switch K1 named limSwtLeft
sw1.png
Figure-1:

1. When K1 is not pressed, the logic value of DPin-11 is HIGH. Now, if you execute the following code, the variable val1 will assume 1 (HIGH)

#define limSwtLeft 11
bool val1 = digitalRead(limSwtLeft);

2. When K1 is pressed, the logic value of DPin-11 is LOW. Now, if you execute the following code, the variable val2 will assume 0 (LOW)

#define limSwtLeft 11
bool val1 = digitalRead(limSwtLeft);

sw1.png