Array Declarations

G'Day The more I think I know, I more I find out what I don't know. Am using the DallasTemperature Lib and my 10+temperature scan project is working OK and now want it to actually control stuff with DS2406's. My problem is not fully understanding how the DallasRom[20] array is composed. So here's my list of questions:- 1. What does “DeviceAddress DallasROM[20]” actually mean 2. What does “DeviceAddress deviceAddress” actually mean 3. What type is array DallasRom[20], as I have not declared it in the normal way

I want to extract the one wire family code from the DallasRom[20}, so that I only scan temperature devices and not DS2406's, and can achieve that by modifying the library where deviceAddress[0] has the family code. Could even >>DallasRom to extract the first byte containing the family code. But would rather understand how the coding works to get an effective result. ``` *//MyCode OneWire oneWire(ONE_WIRE_PIN); DallasTemperature sensors(&oneWire); DeviceAddress DallasROM[20]; sensors.begin();

//DallasTemperature.ccp-------------------------------------------------------------- void DallasTemperature::begin(void) {  DeviceAddress deviceAddress;  _wire->reset_search();  while (_wire->search(deviceAddress)) {    if (validAddress(deviceAddress)) {      if (!parasite && readPowerSupply(deviceAddress)) parasite = true;            ScratchPad scratchPad;      readScratchPad(deviceAddress, scratchPad);      if (deviceAddress[0] == DS18S20MODEL) conversionDelay = TEMP_12_BIT; else if (scratchPad[CONFIGURATION] > conversionDelay) conversionDelay = scratchPad[CONFIGURATION];      devices++;    }  } }* ```

DeviceAddress DallasROM[20];

This declares an array of DeviceAddress instances, capable of holding 20 instances, numbered 0 to 19.

DeviceAddress deviceAddress;

This declares a single variable of type DeviceAddress.

Paul, It's the instance I'm having a problem with. As DeviceAddress is declared in DallasTemperature.h by Typedef uint8_t DeviceAddrress[8] Then DeviceAddress DallasROM[20] gives me 20 instances of DeviceAddress[8] Is there a simple way of extracting the first uint8_t from each instance. This is the family code byte that I want to check. Can I somehow treat DallasRom[20] as a multi dimensional array of 20*8

int part = DallasROM[adress][adresspart];

Tks, I am one step closer in understanding arrays. Grant

Did you read this: http://arduino.cc/en/Reference/Array ?

If you have any specific questions, or any question really, feel free to ask and I'll answer to the best of my ability. :)

Tks for your help. I am ok with arrays I declare and know how to use them. Its when I do not declare them I get myself into trouble. But you cleared up my last problem and can now see how they are accessed. Tks again.