water sansor 1

Dependencies:   mbed

sensor.h

Committer:
paris8022
Date:
2017-10-27
Revision:
1:06e9441a6f01
Parent:
0:2b430503298a

File content as of revision 1:06e9441a6f01:

int ledPin = 13; //連接13針上的LED,或者使用板載的LED
int sensor_in = 2; //將濁度傳感器連接到數字引腳2
int pinMode(ledPin,OUTPUT); //將ledPin設為輸出模式
int pinMode(sensor_in,INPUT); //將濁度傳感器引腳設置為輸入模式


while()
   if(digitalRead(sensor_in)== LOW){//讀取傳感器信號 
        digitalWrite(ledPin,HIGH); //如果傳感器為低電平,則開啟
     }else{
        digitalWrite(ledPin,LOW); //如果傳感器為高電平,則關閉LED
     }
}