PIR sensor

Hi,

Im trying to use millis() function to on my LED control by PIR sensor. But I am not usre with my coding. Helps are needed .

Thanks.

int pirSensor = 8;
int ledPin = 7; //relayInput=7

unsigned long previousTime = 0;
const long interval = 10000;

void setup() {
 pinMode(pirSensor, INPUT);
 pinMode(ledPin, OUTPUT);//relayInput
 Serial.begin(9600);  
}

void loop(){
 PIRSensor();
}

void PIRSensor() {
 unsigned long currentTime = millis();
 int sensorValue = digitalRead(pirSensor);
 if (sensorValue == 1) {
  digitalWrite(ledPin,HIGH); // (relayInput, LOW)The Relay Input works Inversly
  Serial.println("Motion detected!");
   if (currentTime - previousTime >= interval){
       previousTime = currentTime;
       digitalWrite(ledPin,LOW); 
 }else{
   digitalWrite(ledPin,HIGH); 
 }
}else {
 digitalWrite(ledPin,HIGH);
}
}