Advance line follower

I need help for building a line follower but advance one. In some track their are multiple path for a single condition, so how can i go for the correct one

Do you mean there are multiple paths which satisfy the condition?

You need to first define what you mean by " the correct one".

I have attach an image with this post (a track basically ) you can see that we have too follow different
paths each time we reach to a condition like 2nd turn(starting from any side) or simply a " T " path,
when this condition comes for 1 st time i have to go right and the in another direction. I hope you understand, But any way thanks for Replying :slight_smile:

Nope I still don’t follow you: do you mean that at an intersection you must turn in a certain direction, but the next time you get to the same intersection you must turn a different way?

If that’s right, what are the criteria?- how do you decide (in words…) which way to go?

Image added here for others…

939c0b79cc47c02c63aa89749ed862618b96beef.png

please tell what should i do at second turn.
if you know any tutorial something that can follow above path will do.

Akshaylakade:
please tell what should i do at second turn.

No, you tell us!

You need to understand in your own mind how to make the decision. Describe the process in words, how you would know which way to turn if you were walking along the line. What would you do the first time? What would you do the second time? How would you (the human you, not your robot) know if it was the 1st, 2nd or 100th time you got to an intersection?

Ok i got it 1st i have to turn right after that when the same condition arrives i have to go left , But tell me how to do this in programming .

Forget the programming, that's the least of your problem for now.

You have to figure out how to do it in your head first. Think about you walking around the track... how would you recognise an intersection? What is it that makes any intersection unique from the others? Then, assuming you can identify an intersection, how would you, walking the course on foot and keeping track of what's going on in your head or on paper, know that you have been there before?

We use sensors to recognise an intersection and it gives a specific set of value as output.

Yeah but how do you know it's the same intersection you were at before, and what's the rule for deciding what to do. Does the sensor say "aha! you've been here before so this time you go that way..." Or do you have some way of saying "aha! I'm here again"

You MUST write down the full algorithm, the process, the steps or whatever you want to call it.

Anyone else want to chip in here? :wink:

Akshaylakade:
We use sensors to recognise an intersection and it gives a specific set of value as output.

Curious, do you have the robot built and is it functioning?

Yes !!! Just completed,has 6 sensors of which 1 is in front " 1 " in this fashion.
2 3 4 5 6
@JimboZA sir the sensor will give me the same output that it has given me before isn't it.
I will upload my code as soon as possible.

Akshaylakade:
has 6 sensors

And what do these sensors sense?

How can you tell if you have been at an intersection before and what are the criteria, the rules, for deciding which way to turn?

As we have to solve the track the right way is one that lead us to the end of track.

Akshaylakade:
As we have to solve the track the right way is one that lead us to the end of track.

That's not what you made me think before but nevertheless.

This is not about programming yet: this is about you figuring out the rules for solving the track.

Forget the robot: as I suggested quite a while ago, imagine yourself walking along the track. What would YOU do at each intersection. How would YOU know that you've been to this intersection before but this time you're approaching on a different path?

If I was you, I'd lay a simple track out on the floor or in the garden and walk round it. Write down what your thought process is at every node.

You keep asking for a programming help: in my opinion you're a long way from coding- you need to figure out the rules first.

JimboZA:
Anyone else want to chip in here? :wink:

No, you're doing a great job getting blood out of this stone, one tiny drop at a time.

I'll wait until we get to the weird requirement like "That works great but I didn't tell you before that it has to work at night."

MorganS:
I’ll wait until we get to the weird requirement like “That works great but I didn’t tell you before that it has to work at night.”

… and by the way when I say “at night” I mean “tonight”.

OP, if you want a turnkey solution, then money can change hands in Gigs and Collaborations.

It seems to me that our OP is in some sort of competition and is way out of his depth. He is hoping for software to solve his problem mainly because he doesn't understand software. He certainly doesn't understand his problem.

Ok i will try that to thanks @JimboZA. but still i want to show you

int k=0;
const int m = 6;
const int l = 5;
const int r = 4;
const int u = 3;
const int led = 13;
const int leftmotr2 = 11;
const int leftmotr1 = 10;
const int rightmotr2 = 9;
const int rightmotr1 = 8;

void setup()
{
pinMode(l,INPUT);
pinMode(r,INPUT);
pinMode(m,INPUT);
pinMode(u,INPUT);
pinMode(leftmotr1,OUTPUT);
pinMode(leftmotr2,OUTPUT);
pinMode(rightmotr1,OUTPUT);
pinMode(rightmotr2,OUTPUT);
pinMode(led,OUTPUT);
}

void loop()
{
digitalWrite(led,HIGH);
int left = digitalRead(l);
int right = digitalRead(r);
int mid = digitalRead(m);
int up = digitalRead(u);

if ( up == 0
&& left == 1 && mid == 0 && right == 1
)
{
Forward();
}

else if ( up == 1
&& left == 0 && mid == 0 && right == 1
)
{
Left();
}

else if ( up == 1
&& left == 0 && mid == 1 && right == 1
)
{
SlowLeft();
}

else if ( up == 1
&& left == 1 && mid == 0 && right == 0
)
{
Right();
}

else if ( up == 1
&& left == 1 && mid == 1 && right == 0
)
{
SlowRight();
}

else if ( up == 1
&& left == 0 && mid == 0 && right == 0
)
{
Stop();
}

else if ( up == 0
&& left == 0 && mid == 0 && right == 0
)
{
Forward();
}
else if ( up == 1
&& left == 0 && mid == 0 && right == 0
)

Right();
}

void Forward()
{
digitalWrite(leftmotr1,HIGH);
digitalWrite(rightmotr1,HIGH);
digitalWrite(leftmotr2,LOW);
digitalWrite(rightmotr2,LOW);

}
void Left()
{

digitalWrite(leftmotr1,LOW);
digitalWrite(rightmotr1,HIGH);
digitalWrite(leftmotr2,LOW);
digitalWrite(rightmotr2,LOW);
}
void SlowLeft()
{
Left();
for(int i=0;i<100;i++)
{
analogWrite(A0,i);
}
}

void Right()
{
digitalWrite(leftmotr1,HIGH);
digitalWrite(rightmotr1,LOW);
digitalWrite(leftmotr2,LOW);
digitalWrite(rightmotr2,LOW);

}
void SlowRight()
{
Right();
for(int i=0;i<100;i++)
{
analogWrite(A1,i);
}
}
void Stop()
{
digitalWrite(leftmotr1,LOW);
digitalWrite(rightmotr1,LOW);
digitalWrite(leftmotr2,LOW);
digitalWrite(rightmotr2,LOW);

}
void Reverse()
{
digitalWrite(leftmotr1,LOW);
digitalWrite(rightmotr1,LOW);
digitalWrite(leftmotr2,HIGH);
digitalWrite(rightmotr2,HIGH);
}