Introduction: Arduino Temperature Sensor Project

This circuit simulates a thermometer

The top number on the LCD Screen is the room temperature

The bottom number on the LCD Screen is the desired temperature

The LED light turns on when the desired temperature is lower than the room temperature. This simulates a fan.

One potentiometer controls the LCD display

One potentiometer controls the desired temperature

Supplies

24 * Jumper Wires

1 * Arduino Uno (And USB Connector)

1 * LCD Screen

1 * LED light

1 * Temperature Sensor

2 * Breadboard (Small)

2 * Potentiometer

2 * 330 OHM Resistor

Step 1: Code

/*
 This sketch simulates a thermometer

  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 330 resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 */

//include the library code:
#include <LiquidCrystal.h>

//initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  lcd.begin(16, 2); //set up the LCD's number of columns and rows
  Serial.begin(9600);
  pinMode(8, OUTPUT); //Set pin 8 to output power
}

void loop() {
  
  float desired = analogRead(A1)/10;
  float read = analogRead(A0); //reading from temperature sensor
  float voltage = read*5;
        voltage /= 1024; //convert to voltage
  float tempC = (voltage - 0.5) * 100; //convert to Celcius
  float tempF = (tempC * (9/5)) + 32; //convert to Fahrenheit
  
  if(desired < tempF){ //detects when desired temperature is less than real temperature
    digitalWrite(8, HIGH); //turns on LED
  } else{
    digitalWrite(8, LOW); //turns off LED
  }
  
   lcd.setCursor(0, 0); //set the cursor to column 0, line 0
   lcd.print(tempF); //prints room temperature to lcd
  
   lcd.setCursor(0, 1); //set the cursor to column 0, line 1                     
   lcd.print(desired); //prints desired temperature to lcd
}

Step 2: Build

The circuit:

* LCD RS pin to digital pin 12

* LCD Enable pin to digital pin 11

* LED to digital pin 8

* LCD D4 pin to digital pin 5

* LCD D5 pin to digital pin 4

* LCD D6 pin to digital pin 3

* LCD D7 pin to digital pin 2

* LCD R/W pin to ground

* LCD VSS pin to ground

* LCD VCC pin to 5V

* 2 * 330 resistor:

* ends to +5V and ground

* wiper to LCD VO pin (pin 3)