phototransistor sensor

They come in different range values and are very simple to use.

But they don't work very well.