I am making a line follower to follow a white line (approx 1.7 cmm wide) on a black track. I am using an array of 5 TCRT5000 (IR led+phototransistor) to detect the line. I was previously working with PID but recently I found a few papers on fuzzy logic. Some of them showed fuzzy logic being better than PID. Is fuzzy logic a better choice than PID for my case? I want my bot to as fast as possible.

P.S- The bot is just following a constant width line on a track with a few slopes of 18 deg.

  • $\begingroup$ Program both algorithms and see which is best for your robot. $\endgroup$
    – NomadMaker
    Mar 31, 2018 at 2:12
  • $\begingroup$ I am participating in a competition and I have 3 weeks. I have a basic PID loop but I am confused if I should spend my time working on fuzzy (beginner to fuzzy logic) or improve my PID. It is a side project btw. $\endgroup$ Mar 31, 2018 at 4:02
  • 1
    $\begingroup$ If you are using a common controller you may be able to find sample code that works.The Google search "Arduino Line Following Code" gave me a boatload of responses. $\endgroup$
    – NomadMaker
    Mar 31, 2018 at 20:53

1 Answer 1


Fuzzy logic is the weaker choice. It would make the robot no longer working. The better idea is to stay within the classical pid control paradigm which is based on mathematics and is teached in universities. Fuzzy logic was only a period in AI history which was restricted to japan in the 1990s and then it was forgotten, because the engineers have recognized that they need a different kind of controller in their robots.

For a classical pid controlled line follower, the current situation is compared with the desired state. This is done by calculating the error value. The algorithm has to minimize the error value which is equal to move the robot closer to the line. This can be done with policy iteration which is a heuristic search technique in the state space. Another option is a neural network which can learn the policy with trial and error. That means the distance to the line is used as the error value, and the weights of the neural networks have to adjust to provide better control signals. This kind of neural network pid control is state of the art in robotics and will result into good results in professional robotics competitions.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.