LCD温度显示报警器

Posted meetrice

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LCD温度显示报警器相关的知识,希望对你有一定的参考价值。

项目地址:https://www.tinkercad.com/things/9Yv09OZnrXy-temperature-sensor-with-display

技术图片

 

 

//CREATED BY GIOVANNI, LUCAS B, LUCAS F & THIAGO.
//WHEN THE TEMPERATURE IS HIGHER THAN 35oC IT PLAYS ANOTHER SOUND FREQUENCY.

//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);

//This is the Arduino Pin that will read the sensor output.
int sensePin = A0;
//The variable we will use to store the sensor input.
int sensorInput;
//The variable we will use to store temperature in degrees.
double temp;

void setup()
{
  //Pin of the led.
  pinMode(13, OUTPUT);
  
  //Initialize the LCD‘s number of columns and rows.
  lcd.begin(16, 2);
  
  //Start the Serial Port at 9600 baud (default).
  Serial.begin(9600);
}

void loop()
{  
  //Set the cursor to column 0, line 0
  lcd.setCursor(0, 0);
  
  //Read the analog sensor and store it.
  sensorInput = analogRead(A0);
  //Find percentage of input reading.
  temp = (double)sensorInput / 1024;
  //Multiply by 5V to get voltage.
  temp = temp * 5;
  //Subtract the offset.
  temp = temp - 0.5;
  //Convert to degrees.
  temp = temp * 100;
  
  if (temp > 35)
  {
    //INPUT - FREQUENCY - TIME THAT LASTS
    tone(8, 800, 300);
    delay(250);
    
      digitalWrite(13, HIGH);
      delay(500); // Wait for 500 millisecond(s)
      digitalWrite(13, LOW);
      delay(500); // Wait for 500 millisecond(s)
  }
  
  else if (temp > 25)
  {
    //INPUT - FREQUENCY - TIME THAT LASTS
    tone(8, 500, 300);
    delay(500);

    digitalWrite(13, HIGH);
    delay(500); // Wait for 500 millisecond(s)
    digitalWrite(13, LOW);
    delay(500); // Wait for 500 millisecond(s)
  }  

  lcd.print("Temperature: ");
  
  //Set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  lcd.print(temp);
  
  lcd.print(" Celsius");

}

 

以上是关于LCD温度显示报警器的主要内容,如果未能解决你的问题,请参考以下文章

燃太TN901红外测温模块LCD1602显示

PCF8591采集温度源码程序---STC89C52实时用PCF8591采集温度LCD显示

PCF8591采集温度源码程序---STC89C52实时用PCF8591采集温度LCD显示

基于CC2530(ZigBee设计)的温度报警器

Proteus仿真UNO+LCD 1602+LM35+RGB灯温度显示

STC单片机LCD1602四线驱动模式显示ADC采样电压和温度