Umair Aftab
/
DS18B20MultipleSensors
Auto search for All DS18B20 sensors on data bus
main.cpp
- Committer:
- umairaftab
- Date:
- 2014-04-13
- Revision:
- 0:a2a81f538133
File content as of revision 0:a2a81f538133:
#include <mbed.h> #include "DS18B20.h" #include "OneWireDefs.h" #define THERMOMETER DS18B20 float temp; // device( mbed pin ) THERMOMETER device(PTC11); void readTemp(int deviceNum) { temp = device.readTemperature(deviceNum); printf("Device %d is %f\n\r",deviceNum, temp); wait(0.5); } int main() { while (!device.initialize()); // keep calling until it works int deviceCount = device.getDeviceCount(); printf("Found %d sensors\n\r",deviceCount); device.setResolution(twelveBit); while (true) { for (int i = 0;i < deviceCount; i++) readTemp(i); } }