Simple DS1820 sensor demo showing how to use the DS1820 library [https://developer.mbed.org/users/hudakz/code/DS1820/]

Dependencies:   DS1820

main.cpp

Committer:
hudakz
Date:
2015-03-19
Revision:
0:77a366f9ba45
Child:
1:fe12bf2ad337

File content as of revision 0:77a366f9ba45:

/*
 * Simple DS1820 sensor demo
 */
 
#include "mbed.h"
#include "DS1820.h"

Serial serial(USBTX, USBRX);

int main() {
    DS1820  ds1820(PA_9);
    
    // detect and initialize DS1820 sensor
    if(ds1820.begin()) {
        ds1820.startConversion();       // start temperature conversion
        wait(1.0);                      // wait to complete temperature conversion
        while(1) {
            serial.printf("temp = %3.1f\r\n", ds1820.read());   // read temperature
            ds1820.startConversion();   // start temperature conversion
            wait(1.0);                  // wait to complete temperature conversion
        }
    } else
        serial.printf("No DS1820 sensor found!\r\n");
}