We are making a PID line follower using arduino for a competition. According to the rules of the competition they will have loops and discontinuations in their track. Can anyone give some idea how we can tackle them using code.

  • 1
    $\begingroup$ pretend that you are the line follower robot and you can only see what the sensor sees ...... what would you see at a discontinuation in the track? ...... what would you do to re-establish view of the line? ..... turn those thoughts into code $\endgroup$
    – jsotola
    Jan 6, 2019 at 18:40

1 Answer 1


What you need is a hierarchical fuzzy controller for crossing detection. The situation, that the black line on the ground has complicated shapes like zigzags and loops is a good opportunity for implementing a program flow which contains of if-then-statements and subfunctions. In contrast, a normal line following robot will need only a simple table, which produces for an input signal of the sensor an output action of the motor, in case of a crossing layout of the path, a more complicated information processing is needed, namely a dedicated program flow which is done in C, Java or Python.

In the easiest implementation, the robot stops if he detects an unusual pattern on the ground and waits for new commands from the human operator. He can drive to the left and follows the path1 or he can stay on the main line and follows path2.

class Detectcrossring:
  def __init__():
    if getsensor()=="crossing":
    else driveforward()
  def getsensor():
    result ="normallane"
    result ="crossing"
    result ="zigzag"
    return result
  def driveforward():
  def askhumanoperator()
    print "crossing detected."
    print "Should i move forward, left, right?"

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.