Array function is not working [SOLVED]

@ sterretje

Okay, I understand.

  1. set the bool true/false = true.
  2. you made the Arduino start checking from sensor 0 and add 1 each time.
  3. If any sensor (0-4) measures anything less than 57:
  4. Set the bool to false.
  5. If bool is true:
  6. do the whole motor thing.

Yes? Because it's triggering now every time. (I've tried changing the 2nd bool to false as well)

#include <NewPing.h>
#include <L298N.h>

#define SONAR_NUM 5 //Number of sensors.
#define MAX_DISTANCE 61 //Maximum distance (in cm) to ping.

//Driver# 1 - Cube Motor# 1.
  //L298N Motor Driver, Outputs 1-2. Cube motor# 1.
    #define ENA 12 //A PWM Pin (~)
    #define IN1 22 //A digital pin
    #define IN2 23 //A digital pin

L298N Motor_Driver_1_RS(ENA, IN1, IN2);

NewPing sonar[SONAR_NUM] = //Sensor object array. 
{   
  NewPing(2, 3, MAX_DISTANCE), //Sensor 1      
  NewPing(4, 5, MAX_DISTANCE), //Sensor 2
  NewPing(6, 7, MAX_DISTANCE), //Sensor 3
  NewPing(8, 9, MAX_DISTANCE), //Sensor 4
  NewPing(10, 11, MAX_DISTANCE) //Sensor 5
};

void setup() 
{
  Serial.begin(9600); //Starts serial monitor at 9600 bauds.
  Motor_Driver_1_RS.setSpeed(90);
}

void loop() 
{ 
  for (uint8_t i = 0; i < SONAR_NUM; i++) //Loop through each sensor and display results.
    { 
    delay(1000); //Wait 50ms between pings (about 20 pings per second)
    Serial.print(i);
    Serial.print("=");
    Serial.print(sonar[i].ping_cm());
    Serial.print("cm ");
    }
  Serial.println();
  Sensor_Trigger();
}

void Sensor_Trigger()
{
  bool isMatch = true;
  for (int sonarCnt = 0; sonarCnt < SONAR_NUM; sonarCnt++)
  {
    if (sonar[sonarCnt].ping_cm() <= 57)
    {
      isMatch = false;
    }
  }

  // if all sensors measure more than 57
  if (isMatch == true)
  {
    Motor_Driver_1_RS.backward();
    Serial.println("Motor Driver 1 L/S is ON - Forward");
    delay(500);
    Motor_Driver_1_RS.stop();
    Serial.println("Motor Driver 1 L/S is OFF");
  }
}