Introduction: A Simple Arduino Based Line Follower

About: I work at RobotZone ( the folks behind Actobotics and ServoCity.com ) in Winfield, KS. I love working on projects with my kids and seeing what they create.

The humble line follower is a great starter project for those getting into robotics. In this instructable we'll go over the steps needed to build one.

Step 1: Parts & Tools

Parts List
QTY
2140 RPM Right Angle Gearmotor
2Right Angle Gearmotor Mount
Comes with two 4-40 x 7/8” Pan Head Phillips Screws
22.55" Press Fit Wheels
1Aruino Leonardo (others such as the Uno would also work)
1Arduino Channel Snap Mount
19v battery
19V Battery Channel Mount
19v snap connector
11.50" Aluminum Channel
1Pololu DRV8835 Dual Motor Driver Shield for Arduino
11x4 stackable female header row
This is optional. I used one of these on one side of the motor controller shield so I would still have access to the 5v and ground pins of the arduino. If you use the included header row pins you can still access ground and 5v the bottom left and bottom right ICSP pins respectively. Also you can solder a header row pin to the "mode" solder paddles near the top of the motor controller... the pin closest to the word "MODE" will give you access to 5v.
1QTR-1RC Reflectance Sensor (2-Pack)
6male-female jumper wires (40 pack)
25 hole beam (585663)
17 hole beam (585664)
19 hole beam (585666)
2Attachment Blocks B (585600)
56-32 nuts (24 pack)
11/2" long 6-32 screw
63/8" long 6-32 screws
21/4" long 6-32 screws
If you get Hardware Pack B from servocity.com it comes with all the 6-32" screws and nuts you'll need for this project and more, plus a 7/64" hex key (alan wrench) for use with 6-32 screws.
2nylon spacer (561-KSP2) 0.125" Long - 0.115" ID - 0.187"OD
(for mounting the sensors)
23/8" 2-56 Socket Head Machine Cap Screw (91251A079)
(for mounting the sensors)
22-56 nut (90480A003)
(you guessed it... for mounting the sensors)

Tools

  • 5/64" hex key(57185A43) (for mounting the sensors)
  • 7/64" hex key(57185A44)
  • small slot head screwdriver (for the screw terminals)
  • soldering iron and solder (to assemble the motor driver sheild)
  • #1 phillips screwdriver for the motor mounts

Step 2: Assemble the Body

I'll let the photos do most of the talking here... especially since I've littered them with notes.

Step 3: Wire It Up

The wiring is fairly easy. Again I added notes to most of these photos - to see the notes view the photos at full size by clicking on them.

Step 4: The Code

Use codebender or the arduino IDE to load this sketch onto your arduino.

Step 5: Test It Out

Your mileage may vary. How far away the sensors are from the table will make a big difference. Adjust the beams to find the best performance in your environment. Lighting, thickness of the line, and contrast from the line to the table will make a difference as well. The greater the contrast the better. You can also tweak the contrastThreashold and/or MaxDesiredSpeed variables in the code. Speed is another consideration, the faster it goes more likely it is to overshoot tight corners. Also keep in mind that as the 9v runs low the bot will go slower.