This sensor is useful for detecting the presence of objects, and is especially well suited to fast-moving objects, or when it is necessary to have a large detection area. It works by shining a laser at a light-sensor. When an object blocks the laser, the sensor is triggered. This could be used to detect a person walking through a doorway, a ball falling through a hoop, or a piece of trash falling into a trash can.

How to use this:

See the attached sketch. The laser does not need to be connected to the same circuitry as the microcontroller and can be positioned a long distance from the detection element.