mingjun xu
/
DS1820_simple_test
A DS1820 temperature sensor test.
Revision 0:3f2965cd42bc, committed 2017-12-06
- Comitter:
- mingjunxu
- Date:
- Wed Dec 06 11:29:36 2017 +0000
- Commit message:
- A simple DS1820 temperture sensor One Wire Test.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DS1820.lib Wed Dec 06 11:29:36 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Sissors/code/DS1820/#236eb8f8e73a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Dec 06 11:29:36 2017 +0000 @@ -0,0 +1,22 @@ +#include "mbed.h" +#include "DS1820.h" +#define DATA_PIN D12 +/*on the DATA_PIN (a 4.7K resistor tp VCC is necessary)*/ + +DS1820 probe(DATA_PIN); + +int main() { + // Initialize the probe array to DS1820 objects + DS1820::unassignedProbe(DATA_PIN); + float celsius, fahrenheit; + + printf("A simple DS1820 Test:\r\n"); + while(1) { + probe.convertTemperature(true, DS1820::all_devices); //Start temperature conversion, wait until ready + celsius = probe.temperature(); + fahrenheit = celsius * 1.8f + 32.0f; + printf("Temperture = %.1f celsius, %.1f fahrenheit.\r\n",celsius, fahrenheit); + wait(1); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Dec 06 11:29:36 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e7ca05fa8600 \ No newline at end of file