BASIC4MCU | 아두이노 | 아두이노 | tkkrlab - Arduino 37 sensors - KY-010 Optical broken module
페이지 정보
작성자 키트 작성일2017-09-13 14:22 조회2,676회 댓글0건본문
Arduino KY-010 Optical broken module
KEYES ARDUINO photo interrupter module
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.
Schematic
If you view from the top like on the photo
- Left = Ground
- Middle = +5V
- Right = Signal
Connect the module to the arduino as follows:
- Arduino pin GND to module GND
- Arduino digital pin 3 to module Signal
- Arduino pin 5V to module 5V
Example Code
1234567891011121314151617181920212223 // Example code for KY-010// photo interrupter moduleint Led = 13 ;// define LED Interfaceint buttonpin = 3; // define the photo interrupter sensor interfaceint val ;// define numeric variables valvoid setup (){pinMode (Led, OUTPUT) ;// define LED as output interfacepinMode (buttonpin, INPUT) ;// define the photo interrupter sensor output interface}void loop (){val = digitalRead (buttonpin) ;// digital interface will be assigned a value of 3 to read valif (val == HIGH) // When the light sensor detects a signal is interrupted, LED flashes{digitalWrite (Led, HIGH);}else{digitalWrite (Led, LOW);}}cs https://tkkrlab.nl/wiki/Arduino_KY-010_Optical_broken_module
댓글 0
조회수 2,676등록된 댓글이 없습니다.