Thats Hot

Published

Introduction: Thats Hot

The Simple Thermostat

Step 1: Project Overview and How To:

This program and build will make a simple thermostat. The screen displays the room temp in Fahrenheit and Celsius, changed by the press of the button, and the Desired Temp. The desired Temperature is set by an Potentiometer will turn on a heater/air conditioning (Represented by the LED) when its set to a certain temp. To build this broject, follow the circuit picture and the use the code.

Troubleshooting:

If this doesnt work after assembled, check to make sure all of the program is present and the wiring is correct

Step 2: Program:

#include <LiquidCrystal.h>

const int buttonPin = 13;

const int temperaturePin = 0;

int sensorPin = 1; float

desiredTemp = analogRead(sensorPin);

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

void setup() {

lcd.begin(16, 2);

Serial.begin(9600);

pinMode(buttonPin, INPUT);

lcd.print("");

pinMode(8,OUTPUT);

}

void loop() {

int buttonState;

float desiredTemp = map(analogRead(sensorPin),0,1023,50,85);

analogRead(sensorPin);

Serial.println(desiredTemp);

float voltage, degreesC, degreesF;

voltage = getVoltage(temperaturePin);

degreesC = (voltage - 0.5) * 100.0;

degreesF = degreesC * (9.0/5.0) + 32.0;

Serial.print("voltage: ");

Serial.print(voltage);

Serial.print(" deg C: ");

Serial.print(degreesC);

Serial.print(" deg F: ");

Serial.println(degreesF);

delay(1000);

buttonState = digitalRead(buttonPin);

lcd.clear();

lcd.setCursor(11,0);

lcd.print("Des.");

if(buttonState== LOW){

lcd.setCursor(0, 1);

lcd.print(degreesC);

lcd.setCursor(0, 0);

lcd.print("Celsius");

lcd.setCursor(11,1);

lcd.print(desiredTemp); }

else {

lcd.setCursor(0, 1);

lcd.print(degreesF);

lcd.setCursor(0, 0);

lcd.print("Fahrenheit");

lcd.setCursor(11,1);

lcd.print(desiredTemp); }

if(desiredTemp >= 75){

digitalWrite(8,HIGH); }

else if(desiredTemp <= 74) {

digitalWrite(8,LOW); }

}

float getVoltage(int pin) { return (analogRead(pin) * 0.004882814); }

Share

    Recommendations

    • Oil Contest

      Oil Contest
    • Casting Contest

      Casting Contest
    • Clocks Contest

      Clocks Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Comments

    Thanks for sharing :)