Is there a Better way to get less false triggers? IR Tripwire style system

Im building a prop for Halloween. Its supposed to trigger a relay when motion is detected (Works great) and the turn the relay off when ANY Ir is detected by the sensor. I dont want it to run off a remote because im using IR laser tag guns that dont have a "Code" to read. It "works" but it gives off ALLOT of false triggers (the IR) to the point that its unusable. Is there a better way to detect IR rather than analogRead?

const int OutPin= D8;
const int InPinM= D6;
const int InPinIR= D5;
int sensorValue = 0;

void setup(){
pinMode(OutPin, OUTPUT);
pinMode(InPinM, INPUT);

void loop(){
if (digitalRead(InPinM) == HIGH)
  digitalWrite(OutPin, HIGH);
while (OutPin == HIGH);
  Serial.println("Waiting For IR");
  if (analogRead(InPinIR) == 0);
    digitalWrite(OutPin, LOW);
Serial.println("Waiting 10");

Have you tried using an average?

If you are just looking for movement, why not use a PIR sensor?

Are you putting a IR only filter or at least a “red” filter on the IR receiver to help?

Have you tried using an average?

No, I'll look into that

Along the lines of an average ...
maybe time how long the IR signal is HIGH for. If you get a constant detection signal for say 200 millis, then it could be a good bet that the signal is not random interference. A bit of experimenting with the times should reduce the random interference. You then might face another problem, whereby, if someone runs through the beam at breakneck speed they may not get detected.


If you are just looking for movement, why not use a PIR sensor?

My experience with PIRs outside in a Halloween project was not good. Most of them were "looking" into the setting sun and I experienced an unacceptably high number of false-positive triggers.