How to use delay() in followline()

Here is my function for my boe bot which follows the line:

void followline(int ss1,int ss2,int ss3,int ss4,int ss5)
{ 
  if(ss2==LOW){softright();}                               //--->line follower segment begins 
  if(ss4==LOW) {softleft();} 
  if(ss3==LOW) {forward();} 
  
  }

Here ae the forward and turn functions I used in line follower:

void forward()                       // forward function
{
     servoLeft.writeMicroseconds(1600);         // Left wheel counterclockwise
     servoRight.writeMicroseconds(1400); }


void softleft()
{
 servoLeft.writeMicroseconds(1500);   // Left wheel stop
 servoRight.writeMicroseconds(1300);  // Right wheel clockwise
 }

void softright()
 {
   servoLeft.writeMicroseconds(1700);   // Left wheel stop
 servoRight.writeMicroseconds(1500);  // Right wheel clockwise
 }

I want to use delay for the followline function but not for the individual function above, Is there a way to do that ? I tried to use delay() at the end of followline but it does not work.

Please be assured that if called, the delay function works as expected.

Wow. Great description.

well I mean my robot does not stop after delay(); like if i do:

void turnLeft()                      // Sharp Left turn function
{ act="turnLeft";
  servoLeft.writeMicroseconds(1300);         // Left wheel clockwise
  servoRight.writeMicroseconds(1300);        // Right wheel clockwise
  delay(1000);
  
}

then it does not stop after 1 second

I don't see an action that would cause it to stop after the delay, just a return, which incidentally is meant to return an int, not a string.

Yes changed that, I am trying to turn my bot 90 degrees and then stop so that why I want to use delay()

...and now you've changed reply #4, and my comment looks stupid.

But not perhaps as stupid as returning a variable that must have global scope anyway.

my bad that is stupid, well learning from stupidity anyway any idea how I can turn it 90 degree?

No idea at all, because I know absolutely nothing about "it".

It is a boe bot with qti sensors and I am trying to turn it 90 degrees, From internet I thought I could use delay after the sevro speed(like in the function above) but that is not working

...and now I know a very, very little about "it", but I still can't see the code or how it is wired, or configured...

I did something like here:
https://learn.parallax.com/tutorials/robot/shield-bot/robotics-board-education-shield-arduino/chapter-4-boe-shield-bot-14

but my bot does not stop after delay(); is over, Also another question does millis() keeps track of time even after i detach the Servos but everything else is connected.

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