Advertisement
safwan092

Untitled

Jan 23rd, 2024
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <LiquidCrystal_I2C.h>
  3.  
  4.  
  5. #define soll_pin A0
  6. #define motor_pin 3
  7.  
  8. LiquidCrystal_I2C lcd(0x27, 16, 2);
  9.  
  10. const int dry = 535; // value for dry sensor
  11. const int wet = 220; // value for wet sensor
  12. void setup() {
  13. // put your setup code here, to run once:
  14. pinMode(soll_pin, INPUT);
  15. pinMode(motor_pin, OUTPUT);
  16. Serial.begin(9600);
  17. lcd.begin();
  18. lcd.backlight();
  19. }
  20.  
  21. void loop() {
  22. // put your main code here, to run repeatedly:
  23. int soll = analogRead(A0);
  24. // Serial.println(soll);
  25. int Humididy = map(soll, wet, dry, 100, 0);
  26. if (Humididy <= 0)
  27. Humididy = 0;
  28. lcd.setCursor(1, 0);
  29. lcd.print("Humididy= ");
  30. lcd.setCursor(11, 0);
  31. lcd.print(Humididy);
  32. lcd.print(" % ");
  33. delay(1000);
  34. //lcd.clear();
  35. Serial.print(Humididy);
  36.  
  37. Serial.println("%");
  38. delay(100);
  39. if (Humididy <= 50)
  40. {
  41. digitalWrite(motor_pin, LOW);
  42. delay(1000);
  43. }
  44. else {
  45. digitalWrite(motor_pin, HIGH);
  46. delay(1000);
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement