3pi fail to detect end point


I am using attached path for 3pi line follower. The given image is for end of the path.So please help to modify 3pi line follower code to stop the 3pi robot at the stop position as per the attached image is showing. Please advice to modify the 3pi Arduino code or AVR code

The line with is recommended 3pi line with ( Electrical tape )

please help



Have you tried making the modifications you are asking for? If so, can you post what you have tried so far?

It looks like you might be able to detect the goal by checking the outter two sensors and seeing if they are both sensing a dark surface at the same time (assuming this is the only time it would happen throughout the course). This is similar to how the example maze solving code for the 3pi works, except it checks the middle 3 sensors instead of the outter 2. You can see the logic for doing this in the “The Main Loop(s)” subsection of the “Example Project #2: Maze Solving” section in the 3pi user’s guide.



Still I did not fine the code location in the Arduino code. Can toy please advice the code location related to above modification

As per your point out following modification can be done

// Check for a straight exit.
if(sensors[1] > 200 || sensors[2] < 100 || sensors[3] > 200)
found_straight = 1;

I adjusted middle sensor " sensors[2] > 100 "

So what about sensor 0 and 4 status . Shouldn’t we need to check it out ?

Please advice
Thanks in advance

You could probably just check to see if the two outter sensors (0 and 4) are seeing a dark surface and maybe the center sensor to see if it is seeing a light surface. Sensors 1 and 3 are probably not as important to check for this finish condition, since it seems like they could potentially be over the light or dark if the robot comes in at a slight angle. Also, the snippet of code you posted is checking if any of those conditions are true (using an OR comparison); since you want to check if all of the conditions are true, you should use an AND. The if statement to check those senors would look something like this:

if(sensors[0] > 200 && sensors[2]<200 && sensors[4]>200){   // Check end conditions
  // Reached goal

Where to put this in your code depends on how your code is written. In general, it should probably go just after reading the sensors (e.g. the read_line command) and be part of your main loop so it happens every cycle. If you try adding this to your code and have problems, you can post your code here with a description of what it is doing wrong, and I would be glad to take a look.


Dear Brandom
Really Grate advice and help

Your code example is well understand to me now

I am planing to modify pololu 3pi maze follower original code to suite to end point as image showing my first post. That is why I asked to location to modify the code of original pololu source code.

Can you please advice to modify with location it has

Your prompt reply is highly appreciated

Thanks in advance


Have you tried to impliment this change? As I mentioned before, if you try making this change and have problems, I would be glad to look at your modified code. The comments in the code found in the “The Main Loop(s)” section of the 3pi user’s guide that I linked to before should make it clear which part of the code is used to test for the ending condition (between line 38 and 42 of the second chunk of code). If you have more specific questions about the code or problems understanding what it is doing, I would be glad to help clarify.


Dear BrandonM

Yes it is working I Have done it

Thanks for pololu supper support

1 Like