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 /* This is a thermometer using DS1820. With DS1820 library 00002 of Michael Hagberg, I just used most of the sample cords. 00003 Please see notebook [http://mbed.org/users/jf1vrr/notebook/ds1820-thermometer/]. 00004 */ 00005 #include "mbed.h" 00006 #include "TextLCD.h" 00007 #include "DS1820.h" 00008 00009 TextLCD lcd(p24, p26, p27, p28, p29, p30); 00010 00011 const int MAX_PROBES = 1; 00012 DS1820* probe[MAX_PROBES]; 00013 00014 int main() { 00015 int i; 00016 int devices_found=0; 00017 // Initialize the probe array to DS1820 objects 00018 for (i = 0; i < MAX_PROBES; i++) 00019 probe[i] = new DS1820(p19); 00020 // Initialize global state variables 00021 probe[0]->search_ROM_setup(); 00022 // Loop to find all devices on the data line 00023 while (probe[devices_found]->search_ROM() and devices_found<MAX_PROBES-1) 00024 devices_found++; 00025 // If maximum number of probes are found, 00026 // bump the counter to include the last array entry 00027 if (probe[devices_found]->ROM[0] != 0xFF) 00028 devices_found++; 00029 00030 lcd.cls(); 00031 if (devices_found==0) 00032 lcd.printf("No devices found"); 00033 else { 00034 lcd.printf("DS1820 Thermo" ); 00035 while (true) { 00036 probe[0]->convert_temperature(DS1820::all_devices); 00037 lcd.locate(0,1); 00038 for (i=0; i<devices_found; i++) { 00039 lcd.printf("%4.1fc",probe[i]->temperature('c')); 00040 } 00041 } 00042 } 00043 }
Generated on Wed Jul 13 2022 03:10:09 by
1.7.2