Alastair D'Silva / Mbed 2 deprecated stm32f103c8t6-ds18b20

Dependencies:   DS1820 mbed-STM32F103C8T6 mbed

Fork of stm32f103c8t6-ds18b20 by Alastair D'Silva

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "stm32f103c8t6.h"
00002 #include "mbed.h"
00003 #include "DS1820.h"
00004 
00005 #define DATA_PIN        PA_8
00006  
00007 int main() {
00008     DS1820 probe(DATA_PIN);
00009     
00010     while(1) {
00011         printf("Initiating temperature conversion\r\n");
00012         probe.convertTemperature(true, DS1820::this_device);         //Start temperature conversion, wait until ready
00013         double temperature = probe.temperature();
00014         int temp_integer = temperature;
00015         int temp_milli = (temperature - temp_integer) * 1000;
00016         printf("It is %d.%03dC\r\n", temp_integer, temp_milli);
00017         wait(1000);
00018     }
00019 }