Introduction: Arduino LED Temperature Indicator With LCD

This design is made to show temperature. The different leds indicate if it the temperature in a room is too cold, too hot or fine and the temperature is shown on the LCD in degrees celsius. If it is too cold it will light the blue light, if it is too hot the red light and when the temperature is good the green light. The parameters can be changed in the code, if the code doesn't get changed it will be too hot at 25 degrees en too cold at 18 degrees.

Step 1: Get the Parts

The things you'll need:

- Arduino board

- Breadboard

- Jumper wires

- 3 220Ω resistors (red-red-brown)

- 3 LEDs (blue, green red)

- A temperature sensor (we used a DEBO DHT 11, but most should work)

- LCD with I2C backpack

Step 2: Put Parts in Place

Put the parts in the right place as shown on the pictures. Everything needs to be connected to the same Arduino board, the second picture it there to clarify how to connect the LCD.

For some clarity on the wires:

- Red LED goes to digital pin 4 through one of the resistors, and ground

- Green LED goes to digital pin 3 though a resistor, and ground

- Blue LED goes to digital pin 2 through a resistor, and ground

- Pin one (the pin on the left) of the temperature sensor goes to 5v

- Pin two (the pin in the middle) of the temperature sensor goes to analog pin A2

- Pin three (the pin on the right) of the temperature sensor goes to ground

Step 3: Coding

Connect the arduino to the computer and upload this code:

#include "DHT.h"

#define DHTPIN 5
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

const int hot = 25; //set hot parameter
const int cold = 18; //set cold parameter
#include "Wire.h"
#include "LCD.h"
#include "LiquidCrystal_I2C.h"
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);

void setup() {

  pinMode(2, OUTPUT); //blue
  pinMode(3, OUTPUT); //green
  pinMode(4, OUTPUT); //red
  Serial.begin(9600);
  dht.begin();  lcd.begin (16,2);
  lcd.setBacklightPin(3, POSITIVE);
  lcd.setBacklight(HIGH);
}
void loop() {

  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);


  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }


  float tempC = t;

  lcd.clear();
  lcd.home();
  lcd.print("temperatuur: ");
   lcd.setCursor (0,1);
   lcd.print(tempC);
  lcd.print(" Graden C");



  Serial.print("temp: ");
  Serial.print(tempC);
  if (tempC < cold) { //cold
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    Serial.println(" It's Cold.");
  } else if (tempC >= hot) { //hot
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    Serial.println(" It's Hot.");
  } else {
    digitalWrite(2, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
    Serial.println(" It's Fine.");
  }
  delay(1000);
}

Step 4: Make a Casing (optional)

If you like, you can make a casing out of carton or wood to make it look nice. The casing on the pictures is a spray painted piece of carton. When making a casing, make sure you don't forget holes for the lights, the LCD and a hole for the power input.