BASIC4MCU | 아두이노 | 아두이노 | tkkrlab - Arduino 37 sensors - KY-017 Mercury open optical module
페이지 정보
작성자 키트 작성일2017-09-13 14:27 조회2,632회 댓글0건본문
Arduino KY-017 Mercury open optical module
Part of Dealextream 37 sensors in a 1 kit
Mercury switch module and a digital interface, built-in 13 LED build a simple circuit to produce tilt warning lamp 13 comes with digital interfaces of the LED, the mercury tilt switch sensor interface to access digital 3, when the tilt switch sensor senses a key signal, LED lights, otherwise off.Schematic
- Arduino GND --> Pin - of module
- Arduino 5+ --> Pin middel of module
- Arduino 3 --> pin S of module
Example code
123456789101112131415161718192021 //KY017 Mercury open optical moduleint Led = 13 ;// define LED Interfaceint buttonpin = 3; // define the mercury tilt switch sensor interfaceint val ;// define numeric variables valvoid setup (){pinMode (Led, OUTPUT) ;// define LED as output interfacepinMode (buttonpin, INPUT) ;// define the mercury tilt switch sensor output interface}void loop (){val = digitalRead (buttonpin) ;// read the values assigned to the digital interface 3 valif (val == HIGH) // When the mercury tilt switch sensor detects a signal, LED flashes{digitalWrite (Led, HIGH);}else{digitalWrite (Led, LOW);}}cs https://tkkrlab.nl/wiki/Arduino_KY-017_Mercury_open_optical_module
댓글 0
조회수 2,632등록된 댓글이 없습니다.