0% found this document useful (0 votes)
10 views3 pages

Document (24) .

This code is for an Arduino project that uses a soil moisture sensor and a LiquidCrystal display. It reads the soil moisture level, displays the value and percentage on the LCD, and indicates whether the soil is dry, wet, or okay. If the soil is dry, it prompts to water the plant and updates the display accordingly.

Uploaded by

chicknalia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Document (24) .

This code is for an Arduino project that uses a soil moisture sensor and a LiquidCrystal display. It reads the soil moisture level, displays the value and percentage on the LCD, and indicates whether the soil is dry, wet, or okay. If the soil is dry, it prompts to water the plant and updates the display accordingly.

Uploaded by

chicknalia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Here is the code again, without any invisible characters:

```

#include <LiquidCrystal.h>

Const int soilMoisturePin = A0;

Const int lcdRs = 12;

Const int lcdE = 11;

Const int lcdD4 = 5;

Const int lcdD5 = 4;

Const int lcdD6 = 3;

Const int lcdD7 = 2;

Const int dryThreshold = 300;

Const int wetThreshold = 600;

LiquidCrystal lcd(lcdRs, lcdE, lcdD4, lcdD5, lcdD6, lcdD7);

Void setup() {

Lcd.begin(16, 2);

Lcd.setCursor(0, 0);

Lcd.print(“Soil Moisture:”);

Void loop() {

Int soilMoistureValue = analogRead(soilMoisturePin);

Int moisturePercentage = map(soilMoistureValue, 0, 1023, 0, 100);


Lcd.setCursor(0, 1);

Lcd.print(“Value: “);

Lcd.print(soilMoistureValue);

Lcd.print(“ (“);

Lcd.print(moisturePercentage);

Lcd.print(“%)”);

If (soilMoistureValue < dryThreshold) {

Lcd.setCursor(0, 0);

Lcd.print(“Soil is DRY”);

} else if (soilMoistureValue > wetThreshold) {

Lcd.setCursor(0, 0);

Lcd.print(“Soil is WET”);

} else {

Lcd.setCursor(0, 0);

Lcd.print(“Soil is OK”);

If (soilMoistureValue < dryThreshold) {

Lcd.setCursor(0, 0);

Lcd.print(“Watering…”);

Delay(1000);

Lcd.setCursor(0, 0);

Lcd.print(“Soil is WET”);

}
Delay(1000);

```

You might also like