PIR Sensor issue

I am having trouble with learning how to work with a PIR sensor, I found some code for it but I cant seem to find a solution for my issue. what it does is blink the LED really fast going between "motion detected" and "motion Stopped". But I do not know how to get it to blink the LED if it senses motion and not if it does not. I cant figure out what to add or adjust so it will work properly.

int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status

void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as 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
    if (pirState == LOW) {
     
      Serial.println("Motion detected!");
     
      pirState = HIGH;
    }
  }
  else
  {
    digitalWrite(ledPin, LOW); // turn LED OFF
    if (pirState == HIGH) {
     
      Serial.println("Motion ended!");
      
      pirState = LOW;
    }
  }
}

DO NOT MAKE MULTIPLE THREADS ABOUT THE SAME ISSUE! Please read the "how to use this forum" post here: How to use this forum - please read. - Installation & Troubleshooting - Arduino Forum

Which PIR sensor are you using? Not all are interchangeable!

The PIR motion Sensor from sparkfun.com

Until you KNOW that the PIR sensor is wired correctly, and that it is being read correctly, don't blink the LED. Turn it on when you think there is motion. Turn it off when you think that there is no motion.

Validate that the LED turns on, and off, appropriately. THEN, you can change the behavior of the LED (pin) when there is, or is not, motion.