Basic Line Solving Project
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: Components you will need.
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 Array http://www.zagrosrobotics.com/shop/item.aspx?itemid=896
4. Robot chassis :
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 - 6
8. *Small Alligator Clips
*Less Soldering Option
Step 3: Romi Assembly
Follow the instructions for chassis assembly: https://www.pololu.com/docs/0J68
Step 4: Wiring...
A detailed wiring diagram can be found here:
Connect the following with the leads or jumpers :
- Ardumoto Digital pin 2 - QTR Sensor pin1
- Ardumoto Digital pin 4 - QTR Sensor pin2
- Ardumoto Digital pin 5 - QTR Sensor pin3
- Ardumoto Digital pin 6 - QTR Sensor pin4
- Ardumoto Digital pin 7 - QTR Sensor pin5
- Ardumoto Digital pin 8 - QTR Sensor pin6
- Ardumoto Digital pin 9 - QTR Sensor pin7
- Ardumoto Digital pin 10 - QTR Sensor pin8
- Ardumoto GND - QTR Sensor pin GND
- Ardumoto 5V - QTR Sensor pin VCC
- Ardumoto Terminal A 1 - Black wire of Left motor
- Ardumoto Terminal A 2 - Red wire of Left motor
- Ardumoto Terminal B 3 - Black wire of Right motor
- Ardumoto Terminal B 4 - Red wire of Right motor
- Ardumoto Terminal VIN (+) - Positive/Red wire from battery holder (switched)
- Ardumoto Terminal VIN (-) - Negative/Black wire from battery holder
Note : Digital Pin 3 is skipped and used by the Ardumoto motor driver. Ardumoto also uses pins 11, 12, and 13.
If you do not wish to solder, you may use the Alligator clips to extend the jumper wires from the board to the motors and battery packs.
The switch is optional and not necessary with the alligator clips. Simply unclip either the positive or negative battery clip to disconnect power when not in use.
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 :
Download the Sketches and Library here :
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...
The Romi is a lightweight but powerful robot. The battery cartridge holds 6 AA batteries. You may bridge the positive and negative ends with the alligator clips as shown:
The blue clips are the bridge that chain the 4 batteries in the front with the two batteries in the back. The red clip is positive and the black clip in the back is negative.
We found this to be too much power for the “BasicLineFollower” program.
To scale back the power, remove the blue clips and reattach the black clip aside the red clip. This uses the power of 4 batteries instead of 6.
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."
You can adjust the “calibration speed” (the sweeping motion of the sensor across the line) in the highlighted code below.
If you want to adjust the speed of the robot, scroll down to the bottom of the code and you can adjust each motor speed from 0 -255.
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.