Update to use PC_8 on NUCLEO_L073RZ
Fork of DS1820_HelloWorld by
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #define MULTIPLE_PROBES 00002 #define DATA_PIN PC_8 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 DS1820::unassignedProbe(DATA_PIN); 00043 while(1) { 00044 probe.convertTemperature(true, DS1820::all_devices); //Start temperature conversion, wait until ready 00045 printf("It is %3.1foC\r\n", probe.temperature()); 00046 wait(1); 00047 } 00048 } 00049 00050 #endif
Generated on Thu Jul 14 2022 04:30:58 by 1.7.2