ARDUINO SOIL MOISTURE SENSOR
อุปกรณ์
- 1 x Arduino Uno Board
- 1 x FC-28 moisture sensor
- 1 x Breadboard
- 1 x LED
- 1 x Buzzer
- 1 x 200Ω resistor
- Jumper wires
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); } } } |
ไม่มีความคิดเห็น:
แสดงความคิดเห็น