element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum EASY -> Arduino Robot (line following / rescue) gone wrong :(
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 9 replies
  • Answers 6 answers
  • Subscribers 393 subscribers
  • Views 819 views
  • Users 0 members are here
  • arduino 101
  • arduino-robot
  • robotics
  • help!!
  • education help
  • robot kit
  • help!
Related

EASY -> Arduino Robot (line following / rescue) gone wrong :(

the_future
the_future over 8 years ago

Hey guys!

 

Need help! I get this message "Low memory available, stability problems may occur."

then the robot will search for a line but then struggles to follow the path.

 

 

 

CODE from example:

 

/* Robot Rescue

 

 

In this example, the robot enters the line following mode and

plays some music until it reaches its target. Once it finds the

target, it pushes it out of the track. It then returns to the

track and looks for a second target.

 

 

You can make the robot push as many objects as you want to, just

add more to calls to the rescue function or even move that code

into the loop.

 

 

Circuit:

* Arduino Robot

* some objects for the robot to push

* a line-following circuit

 

 

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

#include <Wire.h>

#include <SPI.h>

 

 

void setup() {

  // initialize the Robot, SD card, display, and speaker

  Robot.begin();

  Robot.beginTFT();

  Robot.beginSD();

  Robot.beginSpeaker();

 

 

  // draw "lg0.bmp" and "lg1.bmp" on the screen

  Robot.displayLogos();

 

 

  // display the line following instructional image from the SD card

  Robot.drawBMP("lf.bmp", 0, 0);

 

 

  // play the chase music file

  Robot.playFile("chase.sqm");

 

 

  // add the instructions

  Robot.text("Rescue\n\n place the robot on\n the rescue track\n pushing the\n obstacles away", 5, 5);

  Robot.text("Press the middle\n button to start...", 5, 61);

  Robot.waitContinue();

 

 

  // 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);

 

 

  // use this to calibrate the line following algorithm

  // uncomment one or the other to see the different behaviors of the robot

  // Robot.lineFollowConfig(14, 9, 50, 10);

  Robot.lineFollowConfig(11, 7, 60, 5);

 

 

  // run the rescue sequence

  rescueSequence();

  // find the track again

  goToNext();

  // run the rescue sequence a second time

  rescueSequence();

 

  // here you could go on ...

 

 

}

 

 

void loop() {

  //nothing here, the program only runs once.

}

 

 

// run the sequence

void rescueSequence() {

  //set the motor board into line-follow mode

  Robot.setMode(MODE_LINE_FOLLOW);

 

 

  while (!Robot.isActionDone()) { // wait until it is no longer following the line

  }

  delay(1000);

 

 

  // do the rescue operation

  doRescue();

  delay(1000);

}

 

 

void doRescue() {

  // Reached the endline, engage the target

  Robot.motorsWrite(200, 200);

  delay(250);

  Robot.motorsStop();

  delay(1000);

 

 

  // Turn the robot

  Robot.turn(90);

  Robot.motorsStop();

  delay(1000);

 

 

  // Move forward

  Robot.motorsWrite(200, 200);

  delay(500);

  Robot.motorsStop();

  delay(1000);

 

 

  // move backwards, leave the target

  Robot.motorsWrite(-200, -200);

  delay(500);

  Robot.motorsStop();

}

 

 

void goToNext() {

  // Turn the robot

  Robot.turn(-90);

  Robot.motorsStop();

  delay(1000);

}

  • Sign in to reply
  • Cancel

Top Replies

  • Robert Peter Oakes
    Robert Peter Oakes over 8 years ago +1 suggested
    I assume your using an Arduino UNO for this or at least an ATMEGA328 based controller It is a classic memory hog when you add SD card libraries and the like, you also have sound and graphics on the go…
  • Robert Peter Oakes
    Robert Peter Oakes over 8 years ago in reply to Robert Peter Oakes +1 suggested
    so remove things like Robot.beginSD(); Robot.beginSpeaker(); and the graphics cosmetics like // draw "lg0.bmp" and "lg1.bmp" on the screen Robot.displayLogos(); // display the line following instructional…
  • Robert Peter Oakes
    Robert Peter Oakes over 8 years ago in reply to Robert Peter Oakes +1 suggested
    I missed one, also remove this // play the chase music file Robot.playFile("chase.sqm");
Parents
  • Robert Peter Oakes
    0 Robert Peter Oakes over 8 years ago

    I assume your using an Arduino UNO for this or at least an ATMEGA328 based controller

     

    It is a classic memory hog when you add SD card libraries and the like, you also have sound and graphics on the go. there are a few things you can do to claw back dome memory

     

    1. reduce the size of those text strings (Even temporary to test)

    2. remove the speaker stuff (Again to test)

    3. there may be some things in the library you can also shrink (Buffers are used all over what you have there) and they all take up ram.

    4. if you have one, try and run on an ATMEGA (Arduino MEGA2560)

     

    The one issue with the Arduino Sketches is that if you run out of memory, the ONLY indication you get is the program behaving unexpectedly or crashing altogether. you won't get a trappable error to tell you it failed, it will just start over writing areas of RAM, executing weird parts of code etc. the only way to be sure is to remove bits of code that are not essential to the basic functionality of the project.

     

    the biggest hog you probably have is the SD Card libraries, try find a "LITE" version perhaps or see if there are options to reduce the buffers it uses.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • the_future
    0 the_future over 8 years ago in reply to Robert Peter Oakes

    did what you said but now the robot struggles to move forward and flickers still (display) when moving

    it has not got to the part where it moved the object out the way image

     

    Expected Result >>> https://www.youtube.com/watch?v=bnqDzNAU7JQ&t=601s

     

    Part 2 Talk>>>https://www.element14.com/community/message/215737/l/easy-arduino-robot-line-following-rescue-problem-pt2#215737

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • the_future
    0 the_future over 8 years ago in reply to Robert Peter Oakes

    did what you said but now the robot struggles to move forward and flickers still (display) when moving

    it has not got to the part where it moved the object out the way image

     

    Expected Result >>> https://www.youtube.com/watch?v=bnqDzNAU7JQ&t=601s

     

    Part 2 Talk>>>https://www.element14.com/community/message/215737/l/easy-arduino-robot-line-following-rescue-problem-pt2#215737

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • clem57
    0 clem57 over 8 years ago in reply to the_future

    Have you tried to calibrate?

    // use this to calibrate the line following algorithm

      // uncomment one or the other to see the different behaviors of the robot

      // Robot.lineFollowConfig(14, 9, 50, 10);

      Robot.lineFollowConfig(11, 7, 60, 5);

    Read https://www.arduino.cc/en/Reference/RobotLineFollowConfig to get an idea what you can do to adjust the parameters.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • the_future
    0 the_future over 8 years ago in reply to clem57

    tried it didn't work, i even updated the IDE and the libraries for the robot control and ......EVEN STILL! however now the robot wont move at all and things are move smoother. the robot will go to start then time passed then just stops as if the motors dont exist or as if their is no line.

    There are over people too with the same problem --> https://forum.arduino.cc/index.php?topic=206735.0

     

     

    CODE

     

    /* 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.

     

     

    Circuit:

    * 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

    #include <Wire.h>

    #include <SPI.h>

     

     

    long timerOrigin; // used for counting elapsed time

     

     

    void setup() {

      // initialize the Robot, SD card, display, and speaker

      Robot.begin();

      Robot.beginTFT();

     

     

      // 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);

      Robot.waitContinue();

     

     

      // 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(14, 9, 50, 10);

      Robot.lineFollowConfig(11, 7, 60, 5);

     

     

     

     

      //set the motor board into line-follow mode

      Robot.setMode(MODE_LINE_FOLLOW);

     

     

      // 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!

    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube