Infra red sensor enviroment light problem

hello,

At first I want to say, im new to this forum so sorry if i make some rooky mistakes.

i am writing a code for a project, this project is an interactive beerpongtable with leds under each cup and infrared sensors to detect the cups.

now the code itself is not the thing im stuck on. its the problem of the enviroment light wich triggers the sensors sometimes to a HIGH state when they dont have a cup sitting above them.

my question is: does somebody know how i can fix this? or are here any solutions for?

this is the sensor im using:

have you tried adjusting the pot?

is it behind some sort of transparent glass or plastic? the IR is probably reflecting off that and triggering the sensor without the cup being there

Use modulated IR (38 kHz is common), and look for that. This can filter out environment IR until you take it out into the daylight.

Use a different sensing method, such as light (it's darker when the cup is there: LDR, TSL2561, TEMT6000) or weight (load cell, microswitch, FSR).

Some black acrylic sheet is very transparent to near IR.

The sensor OP uses is not very sensitive for visible light, it is very sensitive to ambient IR. That's very likely their real problem.