10 years, 11 months ago.

how to use the library

I have a little background about c++ programing could you give an example how to use this, like a simple program to check that the sensor is connected?

Question relating to:

1 Answer

10 years, 11 months ago.

Hi, Nizar you can check the mbed Cookbook at: https://mbed.org/cookbook/Homepage

It has plenty of examples where you can learn.

Or if you need something specific, just let me know

Greetings

thanks but I was asking if you can give me an example on how to use DS1820 library.

posted by nizar bakier 15 May 2013

Hi Nizar if you see the contents of ds1820.h in the very first comments of the definition of the library is the example of use that you want, here is the code:

 * Example:
 * @code
 * #include "mbed.h"
 *
 * #include "TextLCD.h"
 * #include "DS1820.h"
 *
 * TextLCD lcd(p25, p26, p21, p22, p23, p24, TextLCD::LCD16x2); // rs, e, d0-d3, layout
 *
 * const int MAX_PROBES = 16;
 * DS1820* probe[MAX_PROBES];
 *
 * int main() {
 *     int i;
 *     int devices_found=0;
 *     // Initialize the probe array to DS1820 objects
 *     for (i = 0; i < MAX_PROBES; i++)
 *         probe[i] = new DS1820(p27);
 *     // Initialize global state variables
 *     probe[0]->search_ROM_setup();
 *     // Loop to find all devices on the data line
 *     while (probe[devices_found]->search_ROM() and devices_found<MAX_PROBES-1)
 *         devices_found++;
 *     // If maximum number of probes are found, 
 *     // bump the counter to include the last array entry
 *     if (probe[devices_found]->ROM[0] != 0xFF)
 *         devices_found++;
 * 
 *     lcd.cls();
 *     if (devices_found==0)
 *         lcd.printf("No devices found");
 *     else {
 *         while (true) {
 *             probe[0]->convert_temperature(DS1820::all_devices);
 *             lcd.cls();
 *             for (i=0; i<devices_found; i++) {
 *                 lcd.printf("%3.1f ",probe[i]->temperature('f'));
 *             }
 *         }
 *     }
 * }
 * @endcode
 */

I hope this will help you. Greetings

posted by Ney Palma 15 May 2013

when i try to compile this program errors comeup for example (" Undefined symbol DS1820::search_ROM() (referred from main.cpp.LPC1768.o)." in file "/" .......) how can i fixe this.

posted by nizar bakier 16 May 2013