Beginner Help Needed

I have been trying for a while to figure out what I'm doing wrong to no avail. The error I get is :

lock:35: error: expected unqualified-id before 'if'

Here is the code:

int buzz = 4;
int dSensor = 3;
int lock = 13;
int dmode;
int lmode;
  
void setup() {
  pinMode(dSensor, INPUT);
  pinMode(buzz, INPUT);
  pinMode(lock, OUTPUT);
  dmode = digitalRead(dSensor);
  lmode = digitalRead(lock);
  Serial.begin(9600);
  
}

void loop() {
  if (digitalRead(buzz) == HIGH) {
    digitalWrite(lock, HIGH);
  }
  else {
    digitalWrite(lock, LOW);
  }
  
  if (dmode != digitalRead(dSensor)) {
    if (digitalRead(dSensor) == HIGH)
      Serial.print("Door open.");
    }
    else {
      Serial.print("Door closed.");
    }
    dmode = digitalRead(dSensor);
  }
  
  if (lmode != digitalRead(lock)) {
    if (digitalRead(lock) == HIGH) {
      Serial.print("Locked");
    }
    else {
      Serial.print("Unlocked");
    }
    lmode = digitalRead(lock);
  }
  
  delay(10);
}

Hello and welcome :slight_smile:

Left brackets count doesn't match right brackets count. Indent your code correctly to see where is the problem. I suggest you use the allman style indentation

Wow, I saw that like a minute after I posted it. I really need to sleep. Heh..

Thanks for the help though, I'll take a look at that link.