top of page
BACK TO HOME PAGE

Project Name : Temperature Control and ALARM.

 

Project Description :

The objective of the project is to create an alarm when a temperature exceeding a certain value that was set as SET POINT. Alarm could be any device or sound source as it triggered a dry contact on a mechanical relay. (not shown yet).

 

Components :

Green Led - lit when temperature OK. Below set point.

Red Led - Lit when temperature NOT OK. Huger than the set point. An Alarm triggered!

LCD Display - Type - 1602. Upper line shows the actual temperature. Lower line shows the set point  temperature.

Left Blue Potentiometer –10K - To adjust the desired set point.

Right Blue Potentiometer –10KΩ - To to adjust the brightness of the display.

Temperature Sensor - TMP36

 

 contact to                                                    yohizu@gmail.com

 

The code

======

/*
 Temperature Control
 This example code is in the public domain.
Create 15 January 2015
  by Yohi Zucker
 */

 

#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
const int temperaturePin=0;//Temp sensor connected o A)
const int setupPin=1;//Middle pot leg connected to A1
int tempHighRed=13;//Led High Temp
int tempLowYellow=10;//Led Low Temp
 

void setup()
{
  Serial.begin(9600);
pinMode(tempHighRed,OUTPUT);
pinMode(tempLowYellow,OUTPUT);   
 lcd.begin(16,2);//each line has 8 char on the 16 digit display.
}
void loop()
{
   float voltage, degreesC;// floating-point variables
    float degreesC1,voltage1,TempSet;
    // First we'll measure the voltage at the analog pin. Normally
  // we'd use analogRead(), which returns a number from 0 to 1023.
  // Here we've written a function (further down) called
  // getVoltage() that returns the true voltage (0 to 5 Volts)
  // present on an analog input pin.
     voltage=getVoltage(temperaturePin);
     degreesC=(voltage - 0.5) * 100.0;
     
   //  voltage1=getVoltage(setupPin);
   TempSet=analogRead(setupPin)/10.3;
   /*
   The easy way. reading the POT pin give 0-1023.
   dividing by 10 gives rang 0 to ~ 100
   */
   
  degreesC1=TempSet; //( voltage1 - 0.5) * 100.0;
    
 lcd.clear();
 lcd.setCursor(0,0);//first 8 chars.
  lcd.print("DegC: ");
   lcd.print(degreesC);
  lcd.setCursor(0,1);//pseodo second line' starts at 9th digit.
  lcd.print(" Set: ");
   lcd.print(degreesC1);
 
if (degreesC>=degreesC1)

{
  digitalWrite( tempHighRed,HIGH);
   digitalWrite( tempLowYellow,LOW);
}
else
{
   digitalWrite( tempHighRed,LOW);
   digitalWrite( tempLowYellow,HIGH);
}

  delay(1000);
 
}

float getVoltage(int pin)
{
    // This function has one input parameter, the analog pin number
  // to read. You might notice that this function does not have
  // "void" in front of it; this is because it returns a floating-
  // point value, which is the true voltage on that pin (0 to 5V).
       return (analogRead(pin) * 0.004882814); //1024*0.00488=`5....
       
       }

 

 
 
bottom of page