   }
 } 
 
+
+// this is where obstacle detection and avoidance starts
 #include <NewPing.h>
 double cm[1]; //sensed distance of sonar sensor : 2 represents array(2 sonar sensors)
 int trigger[1] = {40}; //trigger pins assignment  (sends)   

        

}

void reset_path() {
  for(int i = 0; i <20; i++){
    for(int j = 0; j <20; j++){  

    delay(50);

    Serial.println(cm[i]);
  }
}

//dtermines if the locations detected by sonar are occupied or not
void update_grid(int x, int y, int target_x,int target_y){
  updateSonar();
  //distance of object detected
  float sonarleft = cm[0];

//adjust 150 to what you want, 150cm is what i consider accurate
  if(sonarleft <= 150 && sonarleft != 0){
    int unoccupied = sonarleft/25;
    //adjust 25 to what you want. i wanted each box in the grid to be 25x25cm. I will increase this to match the demensions of the robot
    
    //this is to remove obsticales that were there before, but were removed. marks true if no obstacle
    for (int u = 0; u <= unoccupied; u++){
      grid[x + u][y].walkable = true;
    }
