|
Basic Line Solving Robot ProjectThis tutorial will help you create an Arduino based robot that can follow lines.
It has been a few years since we initially posted this Basic Line Following Robot with Arduino tutorial, and it appears so many people found it helpful that we should post an update which runs current Arduino Libraries, includes the newer robot kits that assemble faster/easier, and further explain some of these steps for those who may be very new to robots and Arduino. In this tutorial, the goal and approach is the same as before. We are building and programming a robot that can follow a lined course with the use of an Arduino based micro controller system programmed to run a basic Proportional speed control. Proportional is a simpler and shortened version of a PID control. You can visit these Wikis to learn more about both systems. Proportional Control http://en.wikipedia.org/wiki/Proportional_control Step 1: Build a course...Before you can run the Basic Line Follower, you will need a lined course. Use white poster board, foam board, white board, expanded PVC, or even a white floor or table and create a line course with black electrical tape. You may have sharp corners, but it will run smoother if the turns are gradual. Keep a minimum of 6" between any meandering lines. Step 2: Robot Build List...1. Arduino Uno or Sparkfun RedBoardhttp://www.zagrosrobotics.com/shop/item.aspx?itemid=868 2. Sparkfun Ardumoto shield http://www.zagrosrobotics.com/shop/item.aspx?itemid=782 3. Pololu QTR-8RC Reflectance Sensor Arrayhttp://www.zagrosrobotics.com/shop/item.aspx?itemid=896 4. Robot chassis : Magician http://www.zagrosrobotics.com/shop/item.aspx?itemid=859 or Gobbit http://www.zagrosrobotics.com/shop/item.aspx?itemid=958 5. Jumper Wires http://www.zagrosrobotics.com/shop/item.aspx?itemid=834 6. USB cable which matches your choice of Arduino/Redboard 7. AA batteries Everything to build the robot, except the line sensor, can also be purchased as a discount bundle: Zagros Robotics Starter Kit - Magician Version (http://www.zagrosrobotics.com/shop/item.aspx?itemid=914) or Zagros Robotics Starter Kit - Gobbit Version (http://www.zagrosrobotics.com/shop/item.aspx?itemid=951) Step 3: Robot Assembly...Proportional Control http://en.wikipedia.org/wiki/Proportional_control Updated 3/3/2017 After assembling the chassis per the chassis instructions, secure the battery, Arduino and Ardumoto shield to the chassis. For the Magician we used zip ties, the Gobbit has screws and Velcro included. Next secure the QTR sensor so that it is just slightly above the driving surface. For the Magician we used thin wire so that it was easy to adjust the sensors position but strong enough to hold it, as it might take some adjusting. Try to set the clearance between the ground and the IR sensors (the little black boxes on the QTR board) about 1/8." Also take notice of the orientation of the sensor with the header pins towards the inside as noted in the wiring diagram in the next step. Otherwise, the sensor pins will not match the Arduino sketch and will run wild. The Gobbit has a predefined location for easily screwing the QTR in place which then maintains proper distance and orientation. Step 4: Wiring...A detailed wiring diagram can be found here: http://www.zagrosrobotics.com/files/ZagrosLineMazeFollowWiring_08232015a.pdf Connect the following with the leads or jumpers :
Note : Digital Pin 3 is skipped and used by the Ardumoto motor driver. Ardumoto also uses pins 11, 12, and 13. Important : While the Gobbit should run proper with the connections noted, switching of the red/black motor wires, and/or the A/B side of the Ardumoto may be necessary with the Magician. Step 5: Arduino Sketch...If you are new to Arduino, or need some further detail on how to install the software and where to save Sketches, you can find detailed instructions for windows here : http://www.zagrosrobotics.com/files/ZagrosArduinoInstallation_08232015a.pdf Download the Sketches and Library here : http://www.zagrosrobotics.com/files/ZagrosBasicLineFollower_08232015a.zip Extract the zipfile and move the " BasicLineFollower_08232015a" and “MotorDirTest_08232015a” folders to your Arduino sketches folder. Move the "QTRSensors" folder to the Arduino libraries folder. Plug in your Arduino/Redboard to your computer with the USB cable. Open and upload the “MotorDirTest_08232015a” sketch. Open the Serial Monitor and test your motors for correct wiring. See comments at the top of the sketch to help you make wiring changes if needed. After the motors are turning correctly, open and upload the " BasicLineFollower_08232015a" sketch. Step 6: Test and Tune...Unplug your robot from the USB and set your robot on your lined course and turn it on. You should see the robot turn back and forth over the line and begin following. You can "tune" some of the variables in the sketch to affect its performance. Until you understand how the sketch works, only adjust the couple of variables noted for "Tune." The sketch is only a basic example to help you learn several fundamentals of sensing and motor control. The real fun begins as you tune some of the variables and add further refined control functions while developing an understanding of how to instruct the robot to accomplish tasks. Step 7: Conclusion...Hopefully, with this tutorial, you have gained some basic understandings of control methods like Proportional control and or PID which can be useful in robotics and automated control systems. Additional information on programming and tuning with PID can be found in our Instructable : Programming and basic loop tuning Another fun extension of line following is Maze Solving. With the same robot you made here, you can make it run mazes like this Instructable: http://www.instructables.com/id/Robot-Maze-Solver/ Here are a couple short videos of the robots maneuvering under the conditions we suggested previously : |
|