KY-010 Photo Interrupter Module and Raspberry Pi

In this example we take a look at the KY-010 Photo Interrupter Module and connect this to a Raspberry Pi.

The sensor uses a beam of light between the emitter and the detector to check if the path between both is being blocked by an object


Parts List

Name link
Raspberry Pi3 Raspberry Pi 3 Model B With WiFi & Bluetooth
37 sensor kit 37 IN 1 SENSOR KITS FOR ARDUINO HIGH-QUALITY FREE SHIPPING (Works with Official for Arduino Boards)
connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire



We use pin 40 (GPIO 21) in this example, you can use another GPIO pin.

KY-010 module Raspberry Pi
– (left) GND
middle +3v3
S (right) Pin 40
pi and ky-010 layout
pi and ky-010 layout


pi and ky-010 schematic
pi and ky-010 schematic


Code Examples


code on github

Previous articleKY-011 Two color LED module Raspberry Pi example
Next articleKY-006 Passive Buzzer Module Raspberry Pi example