ATHANASIOS POLITIS / TmpLM74
Embed: (wiki syntax)

« Back to documentation index

TmpLM74 Class Reference

TmpLM74 Class Reference

An LM74 based digital thermometer. More...

#include <TmpLM74.h>


Detailed Description

An LM74 based digital thermometer.

Currently supports SPI peripheral interface

 #include "mbed.h"
 #include "tmpLM74.h"
 
 Serial pc(USBTX, USBRX); // tx, rx
 DigitalOut myled(LED1);

 TmpLM74 Temp74(p5, p6, p7, p8);

 //   mbed connections:
 //                       mosi(p5) to LM74 pin 1, through 10k
 //                       miso(p6) to LM74 pin 1
 //                       sclk(p7) to LM74 pin 2
 //                       miso(p8) to LM74 pin 7

 //TmpLM74.startLM74();       // CAN be used, but NOT necessary (invoked within readTemp(), if needed)

 int main() {

      float TempC;

      pc.printf("HELLO!,  testing LM74 temperature sensor ...\n\r");

      for (int i = 0; i < 10; i++){
          wait(2);
          TempC = Temp74.readTemp();
          pc.printf("Temperature = ");
          if(TempC > MAX_LM74_TEMP) {         // check whether temp is valid
              pc.printf(" ? *C\n", TempC);
          } else {
              pc.printf("%3.1f *C\n", TempC);
          }
          myled = !myled;
      }
      Temp74.shutLM74down();
      while(1){
          wait(1);
          myled = !myled;
      }
 }

Definition at line 83 of file TmpLM74.h.