彥隆 鄭
/
LGZDSensor
water sansor 1
sensor.h@1:06e9441a6f01, 2017-10-27 (annotated)
- Committer:
- paris8022
- Date:
- Fri Oct 27 07:27:57 2017 +0000
- Revision:
- 1:06e9441a6f01
- Parent:
- 0:2b430503298a
123
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
paris8022 | 0:2b430503298a | 1 | int ledPin = 13; //連接13針上的LED,或者使用板載的LED |
paris8022 | 0:2b430503298a | 2 | int sensor_in = 2; //將濁度傳感器連接到數字引腳2 |
paris8022 | 1:06e9441a6f01 | 3 | int pinMode(ledPin,OUTPUT); //將ledPin設為輸出模式 |
paris8022 | 1:06e9441a6f01 | 4 | int pinMode(sensor_in,INPUT); //將濁度傳感器引腳設置為輸入模式 |
paris8022 | 0:2b430503298a | 5 | |
paris8022 | 0:2b430503298a | 6 | |
paris8022 | 1:06e9441a6f01 | 7 | while() |
paris8022 | 0:2b430503298a | 8 | if(digitalRead(sensor_in)== LOW){//讀取傳感器信號 |
paris8022 | 0:2b430503298a | 9 | digitalWrite(ledPin,HIGH); //如果傳感器為低電平,則開啟 |
paris8022 | 0:2b430503298a | 10 | }else{ |
paris8022 | 0:2b430503298a | 11 | digitalWrite(ledPin,LOW); //如果傳感器為高電平,則關閉LED |
paris8022 | 0:2b430503298a | 12 | } |
paris8022 | 0:2b430503298a | 13 | } |