Project27.Photo Interrupter Module ===================================== Description ------------ The KY-010 Photo Interrupter module is a switch that will trigger a signal when light between the sensor’s gap is blocked. This module is suitable for various electronics platforms like Arduino, Raspberry Pi, ESP32 and others. Specification -------------- - Operating Voltage 3.3V ~ 5V - Board Dimensions 18.5mm x 15mm Connect -------- .. image:: /img/connect/27_bb.png Code ----- .. code-block:: c int Led = 13; // define LED pin int buttonpin = 3; // define photo interrupter signal pin int val; //define a numeric variable void setup() { pinMode(Led, OUTPUT); // LED pin as output pinMode(buttonpin, INPUT); //photo interrupter pin as input } void loop() { val=digitalRead(buttonpin); //read the value of the sensor if(val == HIGH) // turn on LED when sensor is blocked { digitalWrite(Led,HIGH); } else { digitalWrite(Led,LOW); } } Phenomenon ----------- .. image:: /img/phenomenon/27.jpg