grid mapping ...... need help in the code !!!!!

hey guys i am making a grid solving robot ...... it has to map a grid that is 59 (rowcol.) and some points of intersection has nodes that the bot must read and then deletes them from the grid .............. i am gonna show you the code but there is a proplem that it starts but after the first node it got stuck in the loop

here is the code :

#include <Servo.h>

define row 9

define col 5

// 2 servo moto
// 5 line track sensor
Servo lm;
Servo rm;
byte ros = 2;
byte ris = 3;
byte cs = 4;
byte lis = 5;
byte los = 6;
boolean counter = 0;
boolean flag = false;
boolean flag1 = false;
int array[row][col];
// Input & Output
void setup() {
lm.attach(9); // left servo motor
rm.attach(8); // right servo motor
pinMode(ros, INPUT); // right outter sensor
pinMode(ris, INPUT); //right inner sensor
pinMode(cs, INPUT); // center sensor
pinMode(lis, INPUT); // left inner sensor
pinMode(los, INPUT); // left outter sensor
int i = 0;
for (int y = 0; y < row; y++) {
for (int x = 0; x < col; x++) {
i++;
array[y][x] = i;
}
};
Serial.begin(9600);
}
// basic motions
// max clkw 1700 , stop 1500 & max anti clkw 1300
void forward() {
lm.writeMicroseconds(1700);
rm.writeMicroseconds(1300);
}

void reverse() {
lm.writeMicroseconds(1300);
rm.writeMicroseconds(1700);

}

void TurnRight90() {
lm.writeMicroseconds(1700);
rm.writeMicroseconds(1700);
}
void TurnRight() {
lm.writeMicroseconds(1700);
rm.writeMicroseconds(1500);
}
void TurnLeft90() {
lm.writeMicroseconds(1300);
rm.writeMicroseconds(1300);
}
void TurnLeft() {
lm.writeMicroseconds(1500);
rm.writeMicroseconds(1300);
}
void stopRobot() {
lm.writeMicroseconds(1500);
rm.writeMicroseconds(1500);
}
// grid genration

void delete_node() {

for (int y = 0; y < row; y++) {
for (int x = 0; x < col; x++) {
if (counter == array[y][x]) {
array[y][x] = 0;
}
}
}
}
// fixed line track " 3ala el wae2f"
void move_track() {

if ((digitalRead(los) == HIGH && digitalRead(lis) == HIGH && digitalRead(cs) == LOW && digitalRead(ris) == LOW && digitalRead(ros) == LOW) ||
(digitalRead(los) == HIGH && digitalRead(lis) == LOW && digitalRead(cs) == LOW && digitalRead(ris) == LOW && digitalRead(ros) == LOW)) {
TurnLeft();
flag = false;
}

if ((digitalRead(los) == LOW && digitalRead(lis) == HIGH && digitalRead(cs) == HIGH && digitalRead(ris) == HIGH && digitalRead(ros) == HIGH) ||
(digitalRead(los) == LOW && digitalRead(lis) == LOW && digitalRead(cs) == HIGH && digitalRead(ris) == HIGH && digitalRead(ros) == HIGH)) {
TurnRight();
flag = false;
}

if (digitalRead(los) == HIGH && digitalRead(lis) == HIGH && digitalRead(cs) == HIGH && digitalRead(ris) == HIGH && digitalRead(ros) == HIGH && flag == false) {
counter++;
forward();
flag = true;

}
if (digitalRead(los) == LOW && digitalRead(lis) == LOW && digitalRead(cs) == LOW && digitalRead(ris) == LOW && digitalRead (ros) == LOW ) {
stopRobot();
flag = false;
}

if (digitalRead(los) == HIGH && digitalRead(cs) == LOW && digitalRead(ros) == HIGH && flag == false) {
counter++;
delete_node();
forward();
flag = true;
}
}

void dry_run() {

if ((counter == 1 || counter == 10 || counter == 11 || counter == 20 || counter == 21 || counter == 30 || counter == 31 || counter == 40 || counter == 41) && flag1 == false) {
TurnRight();
flag1 == true;
}
else if ((counter == 5 || counter == 6 || counter == 15 || counter == 16 || counter == 25 || counter == 26 || counter == 35 || counter == 36 ) && flag1 == false) {
TurnLeft();
flag1 == true;

}
else if (counter == 45 && flag1 == false) {
forward();
delay(3000);
stopRobot();
delay(10000);

}
else move_track();

}

void loop () {

dry_run();
}

rm.attach( 8); // right servo motor

How does someone attach a motor to a smiley face? Glue? ducktape?

Perhaps you should put your code in code tags [ code ] ... [/ code ]

It will help to fix things like this

for (int y = 0; y < row; y++) {
for (int x = 0; x < col; x++) {
i++;
array[y]
= i;
}
};

.
.
.

for (int y = 0; y < row; y++) {
for (int x = 0; x < col; x++) {
if (counter == array[y]
) {
array[y]
= 0;
}
}
}

Much better

What is it doing when it gets stuck and what indicates it found a node?

Its better to keep this on the thread instead of a PM. (you can more answers in the post)

The code is either going into

if (digitalRead(los) == HIGH && digitalRead(lis) == HIGH && digitalRead(cs) == HIGH && digitalRead(ris) == HIGH && digitalRead(ros) == HIGH && flag == false) {
counter++;
forward();
flag = true;

}

or

if (digitalRead(los) == HIGH && digitalRead(cs) == LOW && digitalRead(ros) == HIGH && flag == false) {
counter++;
delete_node();
forward();
flag = true;
}

in order for the counter to get incremented. to then be able to go into

if ((counter == 1 || counter == 10 || counter == 11 || counter == 20 || counter == 21 || counter == 30 || counter == 31 || counter == 40 || counter == 41) && flag1 == false) {
TurnRight();
flag1 == true; <- are you comparing flag1 to TRUE or setting it to TRUE?
}

i want to eliminate this node from the grid ....... when it sees the first node it starts to go forward then turn right ....

Then something is getting triggered when it shouldn't be, so you need to check if your sensors are working properly.

What allows the robot to keep track of the nodes it's been to?

Can you post a picture of your setup?

at first i generate a grid

int i = 0;
  for (int y = 0; y < row; y++) {
    for (int x = 0; x < col; x++) {
      i++;
      array[y][x] = i;
    }
  };

then i have this function that can delete the node when it is found

void delete_node() {

  for (int y = 0; y < row; y++) {
    for (int x = 0; x < col; x++) {
      if (counter == array[y][x]) {
        array[y][x] = 0;
      }
    }
  }
}[code]

[/code]

HOW does the code know when it has found a new node? Are you using wheel encoders to keep track of the position?

An array is fine, but the robot needs to keep track of where its been.

Those are quote tags, not code tags.

HOW does the code know when it has found a new node? Are you using wheel encoders to keep track of the position?

An array is fine, but the robot needs to keep track of where its been.

no i am using 5 line track sensors only ... can i do it without wheel encoders ???

Post a picture of your robot and grid.

can i do it without wheel encoders ???

If you can keep track of the outer limits and the direction the robot has turned, then maybe the code can fill in the rest, but usually no.