Photo Interrupter Module Keyes KY-010 for Arduino, will trigger a signal when light between the sensor’s gap is blocked. The KY-010 Photo Interrupter module consists of an optical emitter/detector in the front and two resistors (1 kΩ and 33 Ω) in the back. The sensor uses a beam of light between the emitter an detector to check if the path between both is being blocked by an opaque object.
Arduino Connections with KY-010 Photo Interrupter Module
Arduino pin GND to module GND
Arduino digital pin 3 to module Signal
Arduino pin 5V to module 5V
Arduino Code for KY-010 Photo Interrupter
// Example code for KY-010 // photo interrupter module int Led = 13; // define LED pin int SendorPin = 3; // define photo interrupter signal pin int val; //define a numeric variable void setup() { pinMode(Led, OUTPUT); // LED pin as output pinMode(SendorPin, INPUT); //photo interrupter pin as input } void loop() { val=digitalRead(SendorPin); //read the value of the sensor if(val == HIGH) // turn on LED when sensor is blocked { digitalWrite(Led,HIGH); } else { digitalWrite(Led,LOW); } }
Results
The following sketch will light up the LED (pin 13) on the Arduino when there’s an object blocking the beam of light between the sensor’s gap. Use visiting card to block beam.
Responses