#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5,4,3,2);
#define ONE_WIRE_BUS 8
int potPin = A0; //input pin
int soil=0;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
float Celsius = 0;
float Fahrenheit = 0;
void setup() {
sensors.begin();
lcd.begin(16, 2);
Serial.begin(9600);
}
void loop() {
int soil = analogRead(potPin) ;
soil = constrain(soil, 485, 1023);
soil = map(soil, 485, 1023, 100, 0);
lcd.setCursor(0,0);
lcd.print("Water Percentage");
lcd.setCursor(0, 1);
lcd.print(soil);
lcd.print("%");
delay(75);
lcd.print(" ");
delay(10000);
lcd.clear();
sensors.requestTemperatures();
Celsius = sensors.getTempCByIndex(0);
Fahrenheit = sensors.toFahrenheit(Celsius);
lcd.setCursor(0,0);
lcd.print("Aquarium Temp");
lcd.setCursor(0, 1);
lcd.print(Celsius);
lcd.print(" Celsius ");
lcd.setCursor(0, 2);
lcd.print(Fahrenheit);
lcd.println(" Fahrenheit ");
delay(10000);
lcd.clear();
}
Comments