This shows you the differences between two versions of the page.
|
pm:prj2025:avaduva:andrei.iacob1009 [2025/05/29 15:31] andrei.iacob1009 [Software Design] |
pm:prj2025:avaduva:andrei.iacob1009 [2025/05/29 15:32] (current) andrei.iacob1009 [Software Design] |
||
|---|---|---|---|
| Line 341: | Line 341: | ||
| checkWater(); | checkWater(); | ||
| } | } | ||
| - | | ||
| delay(10000); //10sec = 10000 | delay(10000); //10sec = 10000 | ||
| counter++; | counter++; | ||
| Line 359: | Line 358: | ||
| lcd.setCursor(0, 1); | lcd.setCursor(0, 1); | ||
| lcd.print("Moisture: " + String(moisture) + " "); | lcd.print("Moisture: " + String(moisture) + " "); | ||
| - | | ||
| if (moisture <= 300) { | if (moisture <= 300) { | ||
| water_count++; | water_count++; | ||
| //Serial.println(water_count); | //Serial.println(water_count); | ||
| - | | ||
| if(water_count == 5){//To wait for the water to go through the pot. | if(water_count == 5){//To wait for the water to go through the pot. | ||
| watering(); | watering(); | ||
| Line 382: | Line 379: | ||
| digitalWrite(TRIG,LOW); | digitalWrite(TRIG,LOW); | ||
| duration_us = pulseIn(ECHO,HIGH); | duration_us = pulseIn(ECHO,HIGH); | ||
| - | | ||
| if (duration_us > 0) { | if (duration_us > 0) { | ||
| distance = 0.017 * duration_us; | distance = 0.017 * duration_us; | ||
| Serial.print(distance); | Serial.print(distance); | ||
| Serial.println(" cm"); | Serial.println(" cm"); | ||
| - | | ||
| if(distance > 8.4) { | if(distance > 8.4) { | ||
| digitalWrite(LED, HIGH); | digitalWrite(LED, HIGH); | ||
| Line 393: | Line 388: | ||
| digitalWrite(LED, LOW); | digitalWrite(LED, LOW); | ||
| } | } | ||
| - | | ||
| } | } | ||
| } | } | ||
| Line 412: | Line 406: | ||
| Serial.println(p); | Serial.println(p); | ||
| Serial.println(); | Serial.println(); | ||
| - | |||
| lcd.setCursor(0, 0); | lcd.setCursor(0, 0); | ||
| lcd.print(String(t)+"C "); | lcd.print(String(t)+"C "); | ||
| Line 439: | Line 432: | ||
| lcd.setCursor(0, 1); | lcd.setCursor(0, 1); | ||
| lcd.print(" (^ O ^)/ "); | lcd.print(" (^ O ^)/ "); | ||
| - | |||
| delay(1000); // Allow LCD to complete before sound starts | delay(1000); // Allow LCD to complete before sound starts | ||
| - | |||
| playMelody(); | playMelody(); | ||
| - | |||
| // After melody, update sensor readings | // After melody, update sensor readings | ||
| lcd.clear(); | lcd.clear(); | ||