In this circuit we have the use of a phototransistor of any type. The 47k resistor can eventually be changed according to the desired sensitivity. The resistor in series with the LED depends on the excitation logic, being 330 ohms for 5 V and 120 ohms for 3.3 V.