Introduction: LCD Thermostat

Build an arduino thermostat that displays the current temperature and a desired temperature set by the user using the potentiometer. when desired temperature a "fan" is turned on which is actually just an LED.

Step 1: Build Circuit

What you will need:

- Jumper Wires

- 16x2 LCD Screen

- 2 poteniometers

- TMP Sensor

- Button

- LED

Step 2: Write Code

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {

Serial.begin(9600);

lcd.begin(16, 2);

pinMode(13, OUTPUT);

}

void loop() {

int tempreading = analogRead(0);

int button = analogRead(1);

int selectC = analogRead(2);

selectC = map(selectC, 0, 1023, 12, 32);

int selectF = (selectC * 9.0 / 5.0) + 32.0;

float voltage = tempreading * 5.0; voltage /= 1024.0;

float temperatureC = (voltage - 0.5) * 100 ;

float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;

int plusF = temperatureF + 2; int minusF = temperatureF - 2;

if (button < 1023) {

lcd.setCursor(0, 0);

lcd.print("Desired: ");

lcd.print(selectF);

lcd.print("F");

lcd.setCursor(0, 1);

lcd.print("Temp: ");

lcd.print(temperatureF);

lcd.print ("F");

}

else {

lcd.setCursor(0, 0);

lcd.print("Desired: ");

lcd.print(selectC);

lcd.print("C");

lcd.setCursor(0, 1);

lcd.print("Temp: ");

lcd.print(temperatureC);

lcd.print ("C");

}

if (selectF >= minusF && selectF <= plusF){

digitalWrite(13, LOW); } else {

digitalWrite(13, HIGH); } delay(1000);

Serial.println(temperatureF); }