Joe Staton
/
max31855Sample
Sample program for the MAX31855. Prints out the temperature read to console.
Diff: main.cpp
- Revision:
- 0:c50a2801c243
- Child:
- 1:6bed4f6f7b35
diff -r 000000000000 -r c50a2801c243 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Oct 22 09:42:16 2012 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" +#include "max31855.h" + +DigitalOut myled(LED1); + +//---------------------------------------------------------- +//SPI Interfaces +SPI testSPI(p11,p12,p13); +//---------------------------------------------------------- + +//---------------------------------------------------------- +//Thermocouples +max31855 max1(testSPI,p21); +//---------------------------------------------------------- + +int main() { + //Initialise chip (starts internal timer) + max1.initialise(); + + //Float value to hold temperature returned + float fvalue = 0; + + while(1) { + //Check if the chip is ready for a reading to be taken + if (max1.ready()==1){ + //Get the reading + fvalue = max1.read_temp(); + + printf("Temperature is: %f\n\r", fvalue); + } + + //Heartbeat signal (not necessary) + myled = !myled; + + //Delay is not required, here simply for test program + wait(0.25); + } +}