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
- 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);
}
}