Photo Interrupter Module (KY-010) [S041]



https://www.youtube.com/watch?v=J3O2_PgEOBI


*GitHubhttps://github.com/rdiot/rdiot-s041.git


* Specs

Photo interupter module use the buildin arduino led. If the sensor is broken the LED is turned on.

Device senses a signal, LED lights, otherwise off.


* Contents

- Connect

S ----- D2

Middle ----- 5V

G ----- GND


- Key Code

int pin = 2;


void loop()

{

  int val = digitalRead(pin);

  Serial.println("digital=" + (String)val + " ");


  if(HIGH == val)

  {

    Serial.println("interrupt=detected---------------------------------------------------------");

    delay(100);

  }

  else{

    Serial.println("interrupt=NONE   ");

    delay(100);

  }

}



Posted by RDIoT
|