I would like to share a project to create a simple optical proximity sensor that can be used as an optical limit switch or used as, for example, a proximity light switch. A special feature in this project is the principle of protection against parasitic infrared study and simple logic of work. It can be used as a basis for development. In the ready-made firmware for the project, there are options, an optical limit switch, an optical light switch, and an optical switch with auto-off time.
More details here (https://catcatcat.d-lan.dp.ua/prostoj-opticheskij-sensor-priblizheniya/)
Use google translator for translation
Additional materials for the project for its repetition:Simple optical proximity sensor (diagram) (https://catcatcat.d-lan.dp.ua/download/prostoj-opticheskij-sensor-priblizheniya-shema/)
Simple optical proximity sensor (draft) (https://catcatcat.d-lan.dp.ua/download/prostoj-opticheskij-sensor-priblizheniya-proekt/) Password to download the project as usual ;)
Simple optical proximity sensor (firmware) (https://catcatcat.d-lan.dp.ua/download/prostoj-opticheskij-sensor-priblizheniya-proshivka/)
Simple optical proximity sensor (firmware, switch mode 2) (https://catcatcat.d-lan.dp.ua/download/prostoj-opticheskij-sensor-priblizheniya-proshivka-rezhim-vyklyuchatelya-2/)
Simple optical proximity sensor (firmware, switch mode) (https://catcatcat.d-lan.dp.ua/download/prostoj-opticheskij-sensor-priblizheniya-proshivka-rezhim-vyklyuchatelya/)
Simple optical proximity sensor (firmware, shutdown delay mode 2 sec.) (https://catcatcat.d-lan.dp.ua/download/prostoj-opticheskij-sensor-priblizheniya-proshivka-shutdown-delay-mode-2-sec/)
Simple optical proximity sensor, 3D model (https://catcatcat.d-lan.dp.ua/download/prostoj-opticheskij-sensor-priblizheniya-3d-model/)
PCB prototype, complete, optical limit switch