Introduction: Line Following Robot

This is a Line Following Robot. It follows a black line that is drawn. It is able to detect the black line through one photocell and one analog light sensor. There is an LED in between the two sensors that gives off red light when the Arduino is powered on. Then, when the light is reflected back, more light is detected when it is reflected on the white surface, compared to when it is reflected on the black surface. Using this, the right and left servo motors move accordingly to turn left or right when the sensors detect white surface rather than black. I used the Parallax BOEBot Robot for Arduino Kit as my base for the robot. Then I placed a breadboard in front of the base to attach all the sensors with the LED to face the black line.

Follow these steps, and you will be able to build your own line following robot! :)

Step 1: Step 1: Parts

Parts needed:

  1. Arduino
  2. Motor Shield (https://www.adafruit.com/products/1438)
  3. LED with 100 ohms resistor
  4. Photo cell with 1K ohms resistor (https://www.adafruit.com/products/161)
  5. GA1A12S202 Log-scale Analog Light Sensor (https://www.adafruit.com/products/1384)
  6. A base for the robot with 2 wheels attached to servo motors ** I used : Parallax BOEBot Robot for Arduino Kit (https://www.adafruit.com/products/749)
  7. A breadboard
  8. A battery with a battery holder
  9. Black marker or black tape with white papers
  10. Tape to tape all the parts together
  11. Wire to connect all the parts (also jumper wires)

Step 2: Step 2: Assemble 1

First, hook up all the sensors!
Connect the photo cell. One end should go to power and the other should connect to the 1K ohms resistor. Then, on the side with the photo cell and the resistor, connect to the analog pin. Next, connect the other end of the resistor to ground. Then connect the LED with the 100 ohm resistor on the breadboard. Finally connect the light sensor to the breadboard according to the label: ground, power, and one analog pin. Then connect all the wires with jumper wires to the Arduino. Make sure that your jumper wires are long enough to reach the Arduino on the base of the robot.

Second, attach the breadboard to the base of the robot.
I used tape since I couldn't really think of anything else, but you can use anything if it is going to be able to attach the breadboard (facing down) to the robot. Then, use more tape to organize the jumper wires.

Step 3: Step 3: Assemble 2

Third, prepare the base of the robot with the motor shield.
I had to screw in the servo motors to the right position. Then, screw in the wheels on the servo motors. To attach the servo motors, find the two servo pins on the corner of the motor shield. Connect the servo motors to the 2 pins. Note the servo number written on the motor shield according to which side of the motor it is attached to (right or left). Then organize the wires around the base so it would not get in the way of the wheels.

Lastly, make the track for the robot.
I used a black marker that I previously owned to draw the black line. To make the line more precise, I first taped the track with the tape that I owned, then I colored the tape with my black marker. Then, I taped the different white papers around to draw a semi-circle track.

Now, you are done! :)

Step 4: Step 4: Code

You can find the code at: http://ardututes.weebly.com/line-following-robot.h...

When working with the code, you will need to adjust the values for the photocell and the light sensor to change directions. To do this, just place the robot with the sensor (comment out the 2 lines of code to attach the servos in the setup) and check the values of the photocell and the light sensor when it is in the middle, right, and left edge of the black line. Then, change the values of the code accordingly for moving the servo motors.

Step 5: Step 5: Move!

When watching at the video, you will notice the Altoid tin that is taped on the Arduino. This is merely just to balance the weight between the breadboard in the front and the Arduino in the back. When the Altoid tin wasn't taped, the robot constantly tipped towards the front when moving.

I hope this was helpful! Have fun building your own line-following robot. If you have any questions or comments, feel free to leave a comment or inbox me! Thank you!

Comments

author
AqeelA13 made it! (author)2017-05-18

does this work with dc geared motors? if not can u please help me out?

author
aequanimitas made it! (author)2015-12-30

nice tutorial, thanks!

author
Arduino Tech made it! (author)2015-01-23

Can we use another photocell instead of the analog sensor ??

author
helenbang made it! (author)helenbang2015-02-15

Yes, of course you can! I just had the sensor with me, so I decided to work with both of them (just for fun)!

author
Magesh Jayakumar made it! (author)2014-12-23

Nice project, why there a long wire attach to it,when the robot moving??

author
helenbang made it! (author)helenbang2015-02-15

The black wire is just the USB cable to my laptop to power the robot. I was missing my batteries, so I had to take the video with the cable attached. :)

author
trus90 made it! (author)2014-06-27

what's on top of the robot, above the motor shield?

Very nice project!!!

author
helenbang made it! (author)helenbang2015-02-15

Its just a protoshield! :) Thank you!

author
carolinebholmes made it! (author)2014-06-17

I saw this on the front tech page and thought "Huh, looks like that thing Matthew was working on"

I should have known it was you. Great work!

author
helenbang made it! (author)helenbang2014-06-17

hahahahahahaha yessss! I got it finally done right before break and now I had the time to post it! Thanks :)

author
nodcah made it! (author)2014-06-16

Voted! Great simple project! =D

author
helenbang made it! (author)helenbang2014-06-17

Thank you!! :D

author
Penolopy Bulnick made it! (author)2014-06-16

This is so cool! I love these little guys!

author
helenbang made it! (author)helenbang2014-06-17

haha thank you! :)

About This Instructable

15,343views

158favorites

License:

Bio: A high school girl. "Don't look, observe. Don't hear, listen"
More by helenbang:Line Following RobotLaughing Lady in the BathroomArduino Capacitive Touch Game
Add instructable to: