วันศุกร์ที่ 28 กันยายน พ.ศ. 2561

Arduino 14 ARDUINO SOIL MOISTURE SENSOR

ARDUINO SOIL MOISTURE SENSOR

                       
 อุปกรณ์
Let’s start with a quick explanation of how this sensor works. Basically, the electrodes (the legs) work as an open circuit. Those electrodes help measure the conductivity of the soil when inserted into the soil. These electrodes when inserted into the soil give an analog value depending on the degree of conductivity of the soil.
Now that you know how this sensor works, use the schematic below to connect your parts.      
          โค้ดงาน
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
void setup() {
Serial.begin(9600);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
}
void loop() {
if(analogRead(A0) > 950 && analogRead(A0) < 1000){
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(500);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
for(int a = 0; a < 10; a++){
digitalWrite(7, HIGH);
delay(500);
digitalWrite(7, LOW);
delay(500);
 }
}
if(analogRead(A0) >= 1000){
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(1000);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
for(int a = 0; a < 10; a++){
digitalWrite(7, HIGH);
delay(200);
digitalWrite(7, LOW);
delay(200);
}
}
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น