Please Help me with my code (using an Arduino UNO)

Hi everyone! I am a beginner at Arduino and am currently using an Arduino UNO. My goal for this project is to create a device (using a PIR) that could accurately blink an LED light whenever someone is close by. But in the PIR's sense, whenever any heat signature is nearby. My code is at the bottom, can anyone help me?

// This is an introduction to all the variables
int ledPin = 11; // LED
int pirPin = 2; // input pin for the PIR sensor
int pirStat = LOW; // we start assuming no motion is detected
int pirState = 0; // variable for reading the status, also the value

void setup() {
pinMode(ledPin, OUTPUT); // the LED is output
pinMode(pirPin, INPUT); // the sensor is input
}

void loop(){
pirState = digitalRead(pirPin); // read input value
if (pirState == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirStat == HIGH){ // if the PIR state is high, it switches on the LED and then turns low again
digitalWrite(ledPin, HIGH);
pirStat = LOW;
}
}
}

I also used this piece of code-

const int ledPin = 11; // LED
const int inputPin = 2; // input pin for the PIR sensor
const int pirState = LOW; // we start assuming no motion is detected
const int val = 0; // variable for reading the status

void setup() {
pinMode(ledPin, OUTPUT); // the LED is output
pinMode(inputPin, INPUT); // the sensor is input
Serial.begin(9600);
}

void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
Serial.println("Motion Detected!");
else {
digitalWrite(ledPin, LOW); // turn LED OFF
(pirState = LOW);
Serial.println("Motion is gone!");
}
}

You have at least one misplaced right curly bracket "}". How can something be HIGH if you are testing on an else path where that thing is LOW ?

Also, read on how to use the millis() function. Otherwise, you are going to turn on your LED for just a few microseconds, not long enough to be seen.

I could add more information upon request but I suspect that you may prefer to do this yourself.

vaj4088:
How can something be HIGH if you are testing on an else path where that thing is LOW ?

Different variable?

TheMemberFormerlyKnownAsAWOL is correct. I knew that pirState and pirStat should not be named so similarly but I got sucked in anyway. Sorry.

    if (pirStat == HIGH){ // if the PIR state is high, it switches on the LED and then turns low again
      digitalWrite(ledPin, HIGH);
      pirStat = LOW;
    }

This part doesn't do anything because you initialize 'pirStat' to LOW and never set it to anything else. It is always LOW so the 'if' condition is never true.