I am having trouble with making my Arduino. I am trying to make it so that when when you press a button it will show the temperature and humidity I have done this in tinkercad but I need help making a liquid temperature sensor and a humidity sensor.
could someone just fix the temperature sensor in this one?
Here is my code
#include <LiquidCrystal.h>
define btn2 12
define btn1 13
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd (2, 3, 4, 5, 6, 7);
int sensorPin = 0;
char* test [] = {"Water", "Humid"};
void setup()
{
Serial.begin(9600);
lcd.begin(16, 3);
lcd.setCursor(0,0);
lcd.print(">");
lcd.setCursor(1,0);
lcd.print("Water and humidity");
lcd.setCursor(0,1);
lcd.print(test[0]);
lcd.setCursor(8,1);
lcd.print(test[1]);
}
void loop(){
if(digitalRead(btn1) == HIGH)
{
delay(100);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Water Temp");
lcd.setCursor(5,1);
lcd.print(test[0]);
lcd.clear();
int reading = analogRead(sensorPin);
float voltage = reading * 5.0;
voltage /= 1024.0;
float temperatureC = (voltage - 0.5) * 100 ;
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
lcd.print(temperatureF);
lcd.println(" degrees F ");
lcd.setCursor(0,1);
lcd.print(temperatureC);
lcd.println(" degrees C ");
}
if(digitalRead(btn2) == HIGH)
{
lcd.clear();
delay(100);
lcd.setCursor(0,0);
lcd.print("Humidity");
lcd.setCursor(5,1);
lcd.print(test[1]);
}
}