for loop and array

// Read sensors
{

  for (int adr = 0x05A; adr <= 0x82; adr++)
  {
  float Sensor  = readDevice(adr);   // addresses from the scanner
    }
  
//

Hi guys. Doing a school project. Reading sensors.

I have 40 IR sensors, each with its own address. I can increment the adress.

I want to create an array with those 40 read values before i read them out later in my code.

Any help is appreciated and thank you very much

If the addresses are consecutive then there would be no need for an array.

If they are not consecutive then you can create an array with the addresses like this

int addrArray[40] = {0x05A, 0x82, etc, etc, etc};

...R

would all read values not just be in "sensor" and be overwritten each tiime?

Each sensor need to give its temp, store that value, meassure next sensor etc... when all sensors are meassured i will use the values.

nissan200sx:
would all read values not just be in "sensor" and be overwritten each tiime?

I don't understand what was in your mind when you wrote that.

Maybe you can post a program that illustrates how you are thinking of using sensor (I presume that is the name of a variable)

...R

float sensorValues[40]; //declare this as a global variable

//then later in the program :
for (int index = 0; index < 40; index++)
  {
  sensorValues[index]  = readDevice(index + 0x05A);
  }