Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #define MULTIPLE_PROBES 00002 #define DATA_PIN A0 00003 00004 00005 #ifdef MULTIPLE_PROBES 00006 00007 #include "mbed.h" 00008 #include "DS1820.h" 00009 00010 #define MAX_PROBES 16 00011 00012 DS1820* probe[MAX_PROBES]; 00013 00014 int main() { 00015 // Initialize the probe array to DS1820 objects 00016 int num_devices = 0; 00017 while(DS1820::unassignedProbe(DATA_PIN)) { 00018 probe[num_devices] = new DS1820(DATA_PIN); 00019 num_devices++; 00020 if (num_devices == MAX_PROBES) 00021 break; 00022 } 00023 00024 printf("Found %d device(s)\r\n\n", num_devices); 00025 while(1) { 00026 probe[0]->convertTemperature(true, DS1820::all_devices); //Start temperature conversion, wait until ready 00027 for (int i = 0; i<num_devices; i++) 00028 printf("Device %d returns %3.1foC\r\n", i, probe[i]->temperature()); 00029 printf("\r\n"); 00030 wait(1); 00031 } 00032 00033 } 00034 00035 #else 00036 #include "mbed.h" 00037 #include "DS1820.h" 00038 00039 DS1820 probe(DATA_PIN); 00040 00041 int main() { 00042 while(1) { 00043 probe.convertTemperature(true, DS1820::all_devices); //Start temperature conversion, wait until ready 00044 printf("It is %3.1foC\r\n", probe.temperature()); 00045 wait(1); 00046 } 00047 } 00048 00049 #endif
Generated on Tue Jul 12 2022 18:33:44 by
1.7.2
DS1820