FindAddress.ino
/*
* FindAddress.ino
* Eric Ayars
* 5/1/12
*
* program to tell us the addresses of any One-Wire devices on the bus.
*
*/
#include "OneWire.h"
#include "DallasTemperature.h"
#define NDevices 16 // Max number of devices for now
OneWire oneWire(10); // Bus on pin 10
DallasTemperature sensors(&oneWire); // pass to the DT library
int N; // number of sensors
DeviceAddress address[NDevices]; // space for addresses
DeviceAddress thisAddress;
void setup() {
Serial.begin(57600);
sensors.begin();
// check for number of devices
N = sensors.getDeviceCount();
Serial.print(N, DEC);
Serial.println(" sensor(s) detected.");
// Find the address for each device
for (byte j=0;j<NDevices;j++) {
if (sensors.getAddress(thisAddress, j)) {
for (byte k=0;k<8;k++) {
Serial.print(thisAddress[k], HEX);
Serial.print(" ");
address[j][k] = thisAddress[k];
}
Serial.println("");
}
}
}
void loop() {
// Do nothing.
delay(1000);
}
Generated by GNU enscript 1.6.4.