What happens here is that the arduino car sees an obstacle and avoids it on the left side, going back to the route.
However when i add this method "pathSquare()" anywhere in the loop(), it doesn't do anything. The code for the method (it should make the car drive in a square path):
void pathSquare(){
for(int i = 1; i < 4; i++){
Serial.println(i);
moveUp();
delay(300);
stopMovement();
turnLeft90();
delay(300);
}
}
Congratulations on finding the information about using code tags. Unfortunately you missed the part about posting your complete code.
Your snippets contain all sorts of variables and function calls and we can have no idea of how they are defined or what they actually do. So there's not much chance of working out what is wrong.
I think you've missed the point here. What we need to see is the complete program THAT HAS THE PROBLEM. Showing us a program that doesn't contain the code that you say doesn't work is completely pointless.
dawnR:
However when i add this method "pathSquare()" anywhere in the loop(), it doesn't do anything. The code for the method (it should make the car drive in a square path):
void pathSquare(){
for(int i = 1; i < 4; i++){
Serial.println(i);
moveUp();
delay(300);
stopMovement();
turnLeft90();
delay(300);
}
}
I think i stated that clearly here. The pathSquare() method doesn't work when i call it inside the loop() method. I tried calling moveUp();
delay(300);
stopMovement();
turnLeft90();
delay(300);
without the for loop but that also doesn't work.
I truly don't understand what is the problem here, i posted the whole code, said that the loop function works with the code inside of it, but when i put pathSquare method instead of that code, it doesn't do what it's supposed to, also i posted the code for pathSquare method. I don't know how else to explain it???