a

Dependencies:   LM75B mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*M0-BOARD LPC11U24 VERSION 1.0 / HI/ENE/WF 09_2014
00002 BULME Graz / Elektronik 29
00003 Alternativ ohne Library für LM75B
00004 */
00005 #include "mbed.h"
00006 #include "LM75B.h"
00007 
00008 DigitalOut  Led1(LED1);
00009 DigitalOut  Led2(LED2);
00010 DigitalOut  Led3(LED3);
00011 DigitalOut  Led4(LED4);
00012 
00013 
00014 
00015 /* function declaration */
00016 void maxTemp();
00017 
00018 
00019 
00020 
00021 //Create an LM75B object at the default address (ADDRESS_0)
00022 LM75B sensor(p28, p27);
00023 int main()
00024 {
00025 //Try to open the LM75B
00026     if (sensor.open()) {
00027         printf("Device detected!\n\r");
00028     while (1) {
00029         
00030         
00031      Led4=1;
00032      wait(0.2);
00033      Led4=0;
00034      wait(0.2); 
00035      
00036      maxTemp() ;
00037         
00038         
00039     //Print the current temperature
00040     printf("Temp = %.1f\n\r", (float)sensor);
00041     //Sleep for 0.5 seconds
00042     wait(0.5);
00043     }
00044     } else {
00045      error("Device not detected!\n");
00046     }
00047     
00048     
00049     
00050     
00051 }
00052 
00053 
00054 void maxTemp() 
00055 {
00056    /* local variable declaration */
00057    
00058  
00059    if (sensor > 29.0) {
00060       Led1=1; 
00061       }
00062    else
00063       Led1=0; 
00064  
00065    //return 0; 
00066    
00067 }