Joe Staton
/
max31855Sample
Sample program for the MAX31855. Prints out the temperature read to console.
main.cpp
- Committer:
- Stavlin
- Date:
- 2012-10-22
- Revision:
- 0:c50a2801c243
- Child:
- 1:6bed4f6f7b35
File content as of revision 0:c50a2801c243:
#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); } }