STM32F103C8T6_DS1820
Dependencies: DS1820 mbed-STM32F103C8T6 mbed
Fork of STM32F103C8T6_DS1820 by
Diff: main.cpp
- Revision:
- 1:93ec3038c226
- Parent:
- 0:ce867244a530
diff -r ce867244a530 -r 93ec3038c226 main.cpp --- a/main.cpp Fri Jan 06 18:07:05 2017 +0000 +++ b/main.cpp Fri Jan 06 19:27:54 2017 +0000 @@ -13,15 +13,15 @@ confSysClock(); //Configure system clock (72MHz HSE clock, 48MHz USB clock) Serial pc(PA_2, PA_3); - DigitalOut myled(LED1); + DigitalOut led(LED1); DS1820 ds1820(PA_9); // substitute PA_9 with actual mbed pin name connected to the DS1820 data pin float temp = 0; int error = 0; if(ds1820.begin()) { while(1) { - ds1820.startConversion(); // start temperature conversion - wait(1.0); // let DS1820 complete the temperature conversion from analog to digital + ds1820.startConversion(); // start temperature conversion from analog to digital + wait(1.0); // let DS1820 complete the temperature conversion error = ds1820.read(temp); // read temperature from DS1820 and perform cyclic redundancy check (CRC) switch(error) { case 0: // no errors -> 'temp' contains the value of measured temperature @@ -33,6 +33,7 @@ case 2: // CRC error -> 'temp' is not updated pc.printf("CRC error\r\n"); } + led = !led; } } else pc.printf("No DS1820 sensor found!\r\n");