how it works

It consists of a photodiode, a semiconductor device that converts light into an electrical current.

source: wikipedia