Use Soil Moisture sensors and LED’s to alert you to when your plants need to be watered.
Functional Parts in the Project:
- Arduino Uno – https://store.arduino.cc/usa/arduino-uno-rev3
- 560 Piece Jumper Wire Kit – https://amzn.to/2MsCLjL
- Soil Moisture Sensor – https://amzn.to/2jEDyjQ
- 220 Ohm Resistors – https://amzn.to/2RiiMD9
- LED Kit – https://amzn.to/2Rjhs2N
- Breadboard Kit – https://amzn.to/2Xih5ei
#define soilSensor1 A0
#define soilSensor2 A1
#define greenLED1 6
#define redLED1 7
#define greenLED2 8
#define redLED2 9
int goodMoisture = 300;
void setup() {
pinMode(greenLED1, OUTPUT);
pinMode(redLED1, OUTPUT);
pinMode(greenLED2, OUTPUT);
pinMode(redLED2, OUTPUT);
Serial.begin(9600);
}
void loop() {
int sensorValue1 = analogRead(soilSensor1);
int sensorValue2 = analogRead(soilSensor2);
Serial.print("Sensor 1 = ");
Serial.print(sensorValue1);
Serial.print(" Sensor 2 = ");
Serial.println(sensorValue2);
if (sensorValue1 < goodMoisture){
digitalWrite(greenLED1, HIGH);
digitalWrite(redLED1, LOW);
} else {
digitalWrite(greenLED1, LOW);
digitalWrite(redLED1, HIGH);
}
if (sensorValue2 < goodMoisture){
digitalWrite(greenLED2, HIGH);
digitalWrite(redLED2, LOW);
} else {
digitalWrite(greenLED2, LOW);
digitalWrite(redLED2, HIGH);
}
delay(1000);
}
Be the first to comment