Ale C.- / TMP175_Example

Description: Example TMP175 Temperature Sensor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "TMP175.h"
00003 DigitalOut myled(LED1);
00004 TMP175 mySensor(p9,p10);
00005 LocalFileSystem local("mbedMemory"); 
00006 
00007 int main(){
00008     char Fmt[100];
00009     float Temp;
00010     mySensor.vSetConfigurationTMP175(SHUTDOWN_MODE_OFF|COMPARATOR_MODE|POLARITY_0|FAULT_QUEUE_6|RESOLUTION_12,0x48); // Address -> A0,A1,A2=0
00011     mySensor.vSetTemperatureLowTMP175(25.0);
00012     mySensor.vSetTemperatureHighTMP175(35.0);
00013     
00014     FILE *fp = fopen("/mbedMemory/TMP175Debug.txt", "w"); 
00015     fprintf(fp, "TMP175/75 mbed NXP:\r\n"); 
00016     for(int k=0;k<100;k++){
00017         Temp=mySensor;
00018         sprintf(&Fmt[0],"Temperature: %f �C\r\n",Temp);
00019         fprintf(fp,&Fmt[0]); 
00020         myled = 1;
00021         wait(0.5);
00022         myled = 0;
00023         wait(0.5);
00024     }
00025     fclose(fp);
00026     while(1);
00027 }