If-value measured over time

Hi! Im new here, so I'm trying my best to be as precise as possible.

I connected a IR-Reviever to A4. It catches a Signal of a pulsed IR-LED.

analogRead outputs something like this:

0
1000
1000
1000
0
1000
1000
1000
0
...

if the Signal is blocked, Analog read looks like this permanentely:
1000
1000
1000
1000
1000
1000
...

What I try to achive is:
If analogRead is 1000 for 200 milliseconds, write "blocked" only once, then wait till the pulses start again.

Hope you guys can help. Thanks!

int irPin = A4;
int Sensor;


 void setup() {
 Serial.begin(9600);
 pinMode(irPin , INPUT);
 } 

 
void loop() {
      
  Sensor = analogRead (irPin);
  Serial.println(Sensor);
  
        
  if (Sensor >= 1000){ // for 200 milliseconds
     Serial.println("blocked");
     // ??? write "blocked" only once - do nothing till the pulses start again
     }
}

Why analog? The values look like they are digital. Your test for >= 1000 is right on the threshold of the values that you are reading. That is really dangerous, a slight change in temperature or phase of the moon could produce a 999. What kind of IR receiver do you have? Can you provide technical information and/or a link?

The other questions are fairly easy to answer, you can use millis() to time the 200ms delay, and you can use State Change Detection (see the example sketch in the IDE) for the print line.

consider (tested)

void loop() {
    static int           blocked = 0;
    static unsigned long msecLst = 0;
           unsigned long msec    = millis();

    Sensor = analogRead (irPin);
 // Serial.println(Sensor);

    if (Sensor >= 1000)  {
        if (0 == msecLst)
            msecLst = msec;
    }
    else
        blocked = msecLst = 0;

    // for 200 milliseconds
    // write "blocked" only once - do nothing till the pulses start again
#define TIMEOUT     2000
    if (! blocked && msecLst && (msec - msecLst > TIMEOUT))  {
        Serial.println("blocked");
        blocked = 1;
    }

}

it's just easier to show rather than try to explain