multiple sensor pointers or array?

I am working on a project with 3 AMG88XX sensors and pointers/objects have allways been a bit of a stumbling block for me.

What I have is a pointer created to the 3 sensors

Adafruit_AMG88xx amg0;
Adafruit_AMG88xx amg1;
Adafruit_AMG88xx amg2;

I then call the routines to read the sensors independently by the name assigned.

Firstly initilasing the sensors using something like

amg0.begin();
amg1.begin();
amg2.begin();

Then reading the data from the sensors.

   intTemp = amg0.rawThermistor();
   amg0.rawPixels(rawPixels);
   intTemp = amg1.rawThermistor();
   amg1.rawPixels(rawPixels);
   intTemp = amg2.rawThermistor();
   amg2.rawPixels(rawPixels);

Is there a way to create these in an array?
so rather than having to repeat the code and functions I am just creating maybe a for loop or something to do all the work when reading the sensors?

    for(int i=0; i<=sensorNumber; i++){
      amg[i].begin();
      intTemp = amg[i].rawThermistor();
      amg[i].rawPixels(rawPixels);
      Serial.print(amgpixels[i-1]);
    }

Or am I doing this totally wrong?

vangalvin:
What I have is a pointer created to the 3 sensors

Adafruit_AMG88xx amg0;

Adafruit_AMG88xx amg1;
Adafruit_AMG88xx amg2;

No, you don't. Those are 3 object (instantiations) of the Adafruit_AMG88xx class.

If you want an array of them, do:

Adafruit_AMG88xx amg88xxArray[3];

Awesome, thank you :slight_smile:

That is much easier!

And those were not pointers you were creating. Just saying.

( Thinking they were pointers may get the poor guy in trouble later.. )

-jim lee

jimLee:
( Thinking they were pointers may get the poor guy in trouble later.. )

Im allways in trouble :wink: Thanks again