Using data from inside an array

Hello,
I'm helping my son with a project, and got stuck trying to use an Adafruit IR camera.

We gor the camera is AMG88xx GridEYE 8x8 IR camera runing fine, but we want to know if there is a value less than 10 inside the array to trigger a different action.

We can trigger the next step with a simple nested if, however, we dont know how to pull/compare the data from the array.

Basically...

if (any value inside the array <= 10) {
    Serial.println("LESS THAN 10");
    delay(1000);
    }
     else Serial.println("MORE THAN 10");
             delay(100);
            return;

This is how the array looks like
[19.50, 19.50, 19.00, 19.00, 19.00, 18.75, 19.25, 18.50,
19.50, 19.75, 19.50, 19.50, 19.50, 19.50, 19.50, 19.25,
19.50, 19.75, 19.50, 19.50, 19.00, 19.25, 19.25, 19.25,
19.50, 19.50, 18.75, 19.25, 19.75, 19.75, 20.00, 19.25,
19.25, 19.75, 19.75, 19.50, 19.25, 19.50, 19.25, 18.75,
19.25, 19.25, 19.00, 19.00, 19.25, 19.25, 18.75, 19.00,
19.00, 19.50, 19.50, 19.00, 19.00, 19.25, 18.50, 18.25,
19.50, 19.00, 18.75, 19.25, 18.75, 18.75, 18.75, 18.50,
]

And here is the code:

#include <Wire.h>
#include <Adafruit_AMG88xx.h>

Adafruit_AMG88xx amg;

float pixels[AMG88xx_PIXEL_ARRAY_SIZE];

void setup() {
  Serial.begin(9600);

  bool status;

  // default settings
  status = amg.begin();
  if (!status) {
    Serial.println("Could not find a valid AMG88xx sensor, check wiring!");
    while (1)
      ;
  }
}


void loop() {
  //read all the pixels
  amg.readPixels(pixels);

  Serial.print("[");
  for (int i = 1; i <= AMG88xx_PIXEL_ARRAY_SIZE; i++) {
    Serial.print(pixels[i - 1]);
    Serial.print(", ");
    if (i % 8 == 0) Serial.println();
  }
  Serial.println("]");
  Serial.println();

  //delay a second
  delay(1000);
}

We appreciate any help from the community.
Thanks.

You already have a loop going through the pixel data. Place your test in such a loop, viz:

  for (int i = 1; i <= AMG88xx_PIXEL_ARRAY_SIZE; i++) {
    Serial.print(pixels[i - 1]);
    Serial.print(", ");
    if (i % 8 == 0) Serial.println();

    if (pixels[i - 1] <= 10) {

      Serial.println("       <= 10 found");
      break;      // use break if all you care about is finding one such pixel

    }

  }

Obvsly you can do what you want inside the if statement checking all the values, or set a flag (boolean variable) true and after the loop use an if statement. That keeps the two things separate.

Also, you can remove the other printing stuff, but maybe leave it in for now as an aid to developing this.

HTH

a7

It seemed familiar to me...

Gack! How rude.

I don't read Armenian, but this

if (pixels[i-1]<20)   menorveinte=true; //nueva linea

seesm to be the idea @alto777 offered, so...

@netorocks what is your problem? Was it not solved over there?

Good luck.

a7

Thanks so much, it did work!!!
we are learning so much!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.