HI_temp_LM75B

Dependencies:   mbed

main.cpp

Committer:
Enenkel
Date:
2015-06-02
Revision:
0:0e33c5501b99

File content as of revision 0:0e33c5501b99:

/***********************************
name:   BERTL_2014_TEST
author: Gottfried Enenkel   HTL BULME
email:  ene@bulme.at
description:
    meßt die Temeratur und zegt sie am PC an     
    
***********************************/
#include "mbed.h"
#include "LM75B.h"
// **************** KONSTANTE ****************
//Create an LM75B object at the default address (ADDRESS_0)
LM75B sensor(p28, p27);    //i²C Sensor Leitungen

DigitalOut pumpe(LED1);
DigitalOut Vauf(LED2);     //Heizungsventil AUF
DigitalOut Vzu(LED3);      //Heizungsventil ZU 
float(Tsoll);              //Soll Temperatur 
float(Tist);
float(Tmp);                // Rechenwert

// ****************** HAUPTPROGRAMM *****************
int main()
{
Vzu=1;          // Vorlaufventil zu machen bis es wirklich zu ist!
wait (90);      // 90 sec lang auf !
Vzu = 0;
    
Tsoll=30;    

//Try to open the LM75B
    if (sensor.open()) {
        printf("Device detected!\n\r");
        while (1) {
           //Print the current temperature
           printf("Temp = %.3f", (float)sensor);
           printf("    Soll Temperatur = %.1f\n\r", (float)Tsoll);
           //Sleep for 0.5 seconds
           wait(0.5);
           
           //zu KALT
           if ((float)sensor < Tsoll-0.2 ) {
               Vauf = 1;
               Vzu = 0;
               }
           //zu WARM    
           if ((float)sensor > Tsoll+0.1 ){
               Vzu = 1;
               Vauf = 0;
               }              
          }
   
    } 
    else {
          error("Device not detected!\n");
    }
}
// *******************  ENDE ************************