Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- #define soll_pin A0
- #define motor_pin 3
- LiquidCrystal_I2C lcd(0x27, 16, 2);
- const int dry = 535; // value for dry sensor
- const int wet = 220; // value for wet sensor
- void setup() {
- // put your setup code here, to run once:
- pinMode(soll_pin, INPUT);
- pinMode(motor_pin, OUTPUT);
- Serial.begin(9600);
- lcd.begin();
- lcd.backlight();
- }
- void loop() {
- // put your main code here, to run repeatedly:
- int soll = analogRead(A0);
- // Serial.println(soll);
- int Humididy = map(soll, wet, dry, 100, 0);
- if (Humididy <= 0)
- Humididy = 0;
- lcd.setCursor(1, 0);
- lcd.print("Humididy= ");
- lcd.setCursor(11, 0);
- lcd.print(Humididy);
- lcd.print(" % ");
- delay(1000);
- //lcd.clear();
- Serial.print(Humididy);
- Serial.println("%");
- delay(100);
- if (Humididy <= 50)
- {
- digitalWrite(motor_pin, LOW);
- delay(1000);
- }
- else {
- digitalWrite(motor_pin, HIGH);
- delay(1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement