Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Arduino Line Follower Robot

  1. Jun 20, 2016 #1

    RaulTheUCSCSlug

    User Avatar
    Gold Member

    I'm looking to build an Arduino that is capable of following a line depending on a colored strip on the ground, either black or white. I think I might use a LDR, but not quite sure where to even start to be honest. My office is having an Arduino contest, and I just want the Arduino to carry paper from the printer to a desk by following a path.

    Basically I'm thinking of this:

    Arduino reads sensor, if sensor comes back as less 0, then Arduino stays stationary, if comes back with 1, then Arduino turns on motor. Here's the tricky part, I want it to curve around corners but have no idea where I would even begin, probably by connecting two servo motors so that one rotates faster than the other and it turns?

    Thanks, if anyone knows of any tutorials or anything online, I would love to look at them. I am fairly new, so some of the tutorials I've looked at have had me kind of stumped.
     
  2. jcsd
  3. Jun 21, 2016 #2

    Borg

    User Avatar
    Gold Member

    Have you tried the Instructables site? There are a bunch of Arduino projects. Maybe you can find one that will get you started.
     
  4. Jun 21, 2016 #3

    RaulTheUCSCSlug

    User Avatar
    Gold Member

  5. Jun 22, 2016 #4

    rcgldr

    User Avatar
    Homework Helper

    I did a similar thing with a Lego Mindstorm RCX back in 2002. The "brick" was oriented to near vertical to reduce the angular inertia about the yaw axis. The small wheels are in the back, with the sensor extended about an inch in front of the brick (can't be seen in photos). In the second attached image, the bot is moving from left to right. It follows the right side of a dark grey line on a white surface. There were 4 shades of "grey", the white board (white), grey electrical tape (light grey), brown electrical tape (dark grey), and black velcro tape (black and not reflective). The black strips were used for "commands", a single strip was a command to u-turn and continue line following, and two black strips in sequence was a command to stop. The light grey tape was used on a "speed" track to create a wide "boundary" for the line following between white and dark grey, allowing for some drifting at full speed (about 40 cm / s), before making corrections. The dark grey line tape was made wider in the turns to avoid losing track of the line.

    The turning was done by initially turning off a motor for coast mode, then if not corrected, stopping a motor for brake mode (and perhaps putting the other motor into coast mode, I don't recall all of the details of the entire sequence). The timing between correction modes was just fixed loops determined by trial and error. U-turns were a canned sequence that started the outside motor forwards, a brief delay, then starting the inside motor backwards, then either going back into line follow mode (strip command) or stop (remote control command). For the strip commands, after a u-turn, the brick went back into line follow mode. The remote controls included forward, stop, left turn, right turn, rotate left, rotate right, u-turn, and begin line follow. The rotates could be continuous spins.
    lego01w.jpg
    lego03w.jpg
     
    Last edited: Jun 22, 2016
  6. Jun 23, 2016 #5

    RaulTheUCSCSlug

    User Avatar
    Gold Member

    Interesting, I've never worked with a Lego Mindstorm, so each different color was able to be given a new function? And how did you account for turning? Did you slow down one of the motors? Or just turn it off?

    I always wanted to play around with a mindstorm when I was younger, but could never afford it. Glad I'm an adult now with a bit more cash flow!
     
  7. Jun 23, 2016 #6

    rcgldr

    User Avatar
    Homework Helper

    This was a fun project in a company sponsored six sigma class (and yes, just like the Dilbert cartoon, there was a prior total quality management class, but the six sigma class had a totally different name).

    The mindstorm sensor includes it's own red LED emitter, which can be turned on so that external lighting variations don't throw it off and so it can be located close to a surface, such as line following. In addition to the white board, I tested various colors of electrical tape to see the midpoint and range of values returned by the sensor for each of the tapes. Since electrical tape is reflective, I also tested with friction tape which is not reflective (velcro tape would also work), in order to get the lowest (darkest) readings.

    For line following correction, there was a sequence of ever increasing correction, but limited to prevent over correction. Turning involved ramping down the inside motor, which included turning it off (coasting) or braking (back emf). The tighter the turn, the slower the mindstorm would move, due to higher cycling rate of correction to follow a curve.

    The mindstorm was programmed to follow the right edge of the following line. To prevent the mindstorm from crossing over the left edge of the tape (a failure mode), I used multiple strips to make the following line wider in the turns to give the mindstorm more room for correction. You can see that in the attached images from my prior post.

    The mindstorm programming is interesting in that it's parallel programming. In this case there were 4 threads. Main - monitors the sensor for black strips, shuts off tracking when black strip encountered, and determines if one or two strips are present, then either uturns and restarts tracking if one strip detected, or stops if two strips detected. Track - main tracking logic. Slowl - ramp down program for left motor. Slowr - ramp down program for right motor. The 4 threads ran in continuous loops and communication between threads used global variables.

    The minimal goal for the class was line following, which only requires detecting two shades of grey (the amount of led light reflected back to the sensor), and using the remote to start or stop the mindstorm. The optional goal was to add track based commands, (in my case I chose u-turn and stop), which would need three shades of grey. In order to set what was a speed record at the time, the fourth shade of grey was chosen to be mimic the reading when the sensor was centered directly over the right edge of the following line (so no turn correction), allowing for some drift on high speed straight sections with minimal correction (the coast mode on inside motor), ending up at a bit over 40 cm/s. Without this fourth shade of grey tape, the regular line following speed was slower due to the rate of cycling between left and right turn correction. Orienting the RCX brick to near vertical greatly improved yaw response time. It was tilted backwards just enough (with some margin) to prevent it from toppling over forward when braking from high speed to a complete stop, although it would straighten up enough to lift the rear wheels off the track (which looked cool).
     
    Last edited: Jun 23, 2016
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Arduino Line Follower Robot
  1. Robotics competition (Replies: 8)

  2. Robot Car (Replies: 2)

Loading...