Go Down

Topic: Arduino Robot won't follow line (Read 8481 times) previous topic - next topic


I just bought the Arduino Robot for my son, and he's working through the included examples. We can't get the line following example to work at all.  We are using black electrical tape on white poster paper, so the line is as dark as it can be and the contrast is good, so that's not the problem. The sensor array is seeing the line properly and correctly distinguishing between black and white, and the LEDs are lighting correctly as I manually move the bot over the paper crossing the line, so the sensors sem fine. But even though the sensors seem to be working properly, the included sample app isn't. It starts, plays the music, instructs to press the middle button, and then the screen says "Done". Most of the time it doesn't even wiggle to calibrate, it just says "Done" and shows a duration of 30-40ms. Occasionally it does try to calibrate, then makes a few rotations on the spot, and then says "Done". Has anyone gotten this example to work properly?

--- Ben


Have you got any serial debug output?

(Sorry, but I don't have the robot, and you didn't post any code)
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


The code is the sample that comes with the Arduino Robot, used as is:

Code: [Select]
/* Robot Line Follow

This sketch demonstrates the line following capabilities
of the Arduino Robot. On the floor, place some black
electrical tape along the path you wish the robot to follow.
To indicate a stopping point, place another piece of tape
perpendicular to the path.

* Arduino Robot

created 1 May 2013
by X. Yang
modified 12 May 2013
by D. Cuartielles

This example is in the public domain

#include <ArduinoRobot.h> // include the robot library

long timerOrigin; // used for counting elapsed time

void setup() {
  // initialize the Robot, SD card, display, and speaker

  // show the logots on the TFT screen
  Robot.drawBMP("lf.bmp", 0, 0); // display background image

  Robot.playFile("chase.sqm");  // play a song from the SD card
  // add the instructions
  Robot.text("Line Following\n\n place the robot on\n the track and \n see it run", 5, 5);
  Robot.text("Press the middle\n button to start...", 5, 61);

  // These are some general values that work for line following
  // uncomment one or the other to see the different behaviors of the robot
  // Robot.lineFollowConfig(11, 5, 50, 10);
  Robot.lineFollowConfig(14, 9, 50, 10);
  //set the motor board into line-follow mode
  // start
  Robot.fill(255, 255, 255);
  Robot.stroke(255, 255, 255);
  Robot.rect(0, 0, 128, 80); // erase the previous text
  Robot.stroke(0, 0, 0);
  Robot.text("Start", 5, 5);
  Robot.stroke(0, 0, 0); // choose color for the text
  Robot.text("Time passed:", 5, 21); // write some text to the screen
  timerOrigin=millis(); // keep track of the elapsed time
  while(!Robot.isActionDone()) {  //wait for the finish signal
    Robot.debugPrint(millis()-timerOrigin, 5, 29);  // show how much time has passed
  Robot.stroke(0, 0, 0); 
  Robot.text("Done!", 5, 45);
void loop() {
  //nothing here, the program only runs once. Reset the robot
  //to do it again!

It has no debug output, status is displayed on the robot TFT.

--- Ben


I just got an Arduino Robot and see the same issue with following the line. Right now, after I reset the robot, it wig-wags as noted,  but stops as soon as it finds the line?? I have also been playing with the lineFollowConfig function to see if I can make headway in getting mine to follow the line. If I get anywhere with it I will update this post with what I did to make it work.

I did do the wheel calibration as the wheels were turning at different speeds.
I find that if I reset the motor control board as well as the robot control board, it will try recalibrating again.

I also had the wheels not gripping very well, and am still working on it.
So far, I have seen that the motors in their brackets have a lot of play when I wiggle them, so I have pushed a thick piece of paper between the motor and motor mount to stabilize. The wheels still slip but not as much.
I think the issue now is that ball bearing mounts, they may need to be shaved down a little to lower the body and place more weight on the wheels.

I am a little disappointed with this issue of Arduino hardware. The overall quality/functionality doesn't compare with the other hardware I have from Arduino (several UnoR3, Due, and shields). I've literally spent days (like other folks) wrestling with the serial communication on the Robot...I think I'm over that now (I hope).


Those are ALL symptoms I am seeing, too. I have calibrated wheels many times, but after a while it starts veering to the side.

And agreed, this device is not up to the quality I expect from Arduino, and it definitely appears to have been shipped before it was fully baked.


--- Ben


Anyone get this line follow to work yet ??
I'm having same issues as all of you....
Thing that confuses me is that I have seen a YouTube video of this line follow working really well....that's why I bought it !!


Awkward question, but does it require starting the robot on the line?  Have you tried that?

I don't have the robot, so this was just a guess.


That code is built around the ArduinoRobot.h library.  Is that library downloaded, properly installed, and available? And of the right version?


Yes started it on the line ....

There seems to be  2 versions of the sketch available with only difference being one has 2 extra imports that don't seem to be needed as if I comment out it compiles ok, runs and just does what I said previously

I have the library and I think it's ok, I'm presuming if it wasn't it would give compile errors ?? I'm new at this so if there is another way to check let me know please

Thanks for your help


Have you guys solved it yet? I have the same problem here even with stock settings. Sometimes it just stops after calibrating the IRs. Not even a wiggle.


Apr 23, 2014, 08:41 am Last Edit: Apr 23, 2014, 09:41 am by Charkoteow Reason: 1
Tried the beta IDE. Things are much smoother now.


Hi everyone,

I used to have the same problem, but now it fixed.
Try to change your port to "cu.usbmordem****", not the "tty.usbmordem".
Hope this will help.


My robot will not work with either line following programs.  I decided to combine elements of the motor test example and the IR array example, and found that when I sent a command to the motor set, the IR data stopped coming back.  When I now loaded
the IRarray example it reported all zeroes.  When I pressed the reset button on the lower board, the IR data resumed correct operation.  The IR response LED's continued to work properly all during this time.  Maybe someone can take this info further.


Perhaps there is a conflict between the library you're using to control the IR and the library you're using to control the motor - for example trying to use the same pins or the same hardware timers.


I had compile the example line following programs using IDE 1.5.6-r2, these was the message shown

Sketch uses 28,616 bytes (99%) of program storage space. Maximum is 28,672 bytes.
Global variables use 2,092 bytes (81%) of dynamic memory, leaving 468 bytes for local variables. Maximum is 2,560 bytes.
Low memory available, stability problems may occur

Go Up