So im quit new to arduino and i only have worked with basic projects earlier. So im going off on vacation and im having a friend look after my plants and i thought it would be nice having a moisture detector. i've got everything hooked up but the code isn't quite working so id wonder if someone could help me fix the code.
i want the LED to constantly light up when i certain value is reached but also change LED depending on the different values that the moisture detector output.
I would sincerely appreciate if someone could help me with this project.
const int VAL_PROBE = 0; // Analog pin 0
const int MOISTURE_LEVEL = 0; // the value after the LED goes ON
void setup() {
Serial.begin(9600);
}
void Dry(int state) {
digitalWrite(11, state);
}
void Humid(int state) {
digitalWrite(13, state);
}
void Water(int state) {
digitalWrite(12, state);
}
void Air(int state) {
digitalWrite(11, state);
digitalWrite(12, state);
digitalWrite(13, state);
}
void loop() {
int moisture = analogRead(VAL_PROBE);
Serial.println(moisture);
if(moisture > 800) {
Dry(HIGH);
} else {
Dry(LOW);
}
delay(1000);
}
void loop2() {
int moisture = analogRead(VAL_PROBE);
Serial.println(moisture);
if(moisture > 300) {
Humid(HIGH);
} else {
Humid(LOW);
}
delay(1000);
}
void loop3() {
int moisture = analogRead(VAL_PROBE);
Serial.println(moisture);
if(moisture > 50) {
Water(HIGH);
} else {
Water(LOW);
}
delay(1000);
}
void loop4() {
int moisture = analogRead(VAL_PROBE);
Serial.println(moisture);
if(moisture > 1000) {
Air(HIGH);
} else {
Air(LOW);
}
delay(1000);
}