GioMac
Published © GPL3+

LCD Thermometer With LEDs And Alarm Signal

An easy project using stuff from the starter kit: Arduino Uno, temperature sensor, 16x2 LCD display, some LEDs and a Piezo.

BeginnerShowcase (no instructions)18,189
LCD Thermometer With LEDs And Alarm Signal

Things used in this project

Story

Read more

Schematics

Schematics

Code

Untitled file

Arduino
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int sensorPin = 0;
float tempC;
void setup() {
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(9, INPUT);
lcd.begin(16, 2);
}
void loop() {
tempC = get_temperature(sensorPin);
lcd.setCursor(0,0);
lcd.print("Temperature: "); 
lcd.setCursor(0,1);
lcd.print (tempC, 1); lcd.print(" "); lcd.print("C");
delay(200);

 if (tempC <= 23){
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(13, LOW);
    noTone(9);
   
  }
 else if (tempC > 26){
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(13, HIGH);
    tone(9, 440, 250);
    delay(500);
    
  }
  else {
    digitalWrite(7, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(13, LOW);
    noTone(9);
  } 
 
}
float get_temperature(int pin) {
float temperature = analogRead(pin);
float voltage = temperature * 5.0;
voltage = voltage / 1024.0;
return ((voltage - 0.5) * 100);
}

Credits

GioMac

GioMac

0 projects • 6 followers

Comments