Autonomous Roving Robot
Build an autonomous roving robot with the Arduino Uno. Following the parts list and code, build the robot. Test the motors using the code on the page called motors. You will test the ultrasonic sensor and incorporate it into your robot to avoid obstacles. See the parts list below and code.
1 - Arduino Uno Micro Controller $30
1 - Seeed Studio Motor Shield V2 $20 1 - Set geared Motors $10 2 - Square Plastic Electrical Box Covers $3.50 4 - Jumper wires with alligator clip ends $3.50 Assorted Arduino jumper wires $1.00 1 - Ultrasonic Sensor $5.00 |
1 - Bag of 5, 10x24x2 Machine screws with nut $3.00
1 - Battery Holder 4xAA with barrel connector $3.00 1 - Battery Holder 4xAA bare ends $2.00 1 - Package Zip Ties $1.99 2 - Robot Wheels $5.00 Approx. $88.00 |
Below is the code use to test the Motors. Use this code and modify it to test the forward, back, left and right functions. It is ok to erase or add to it to see what results you'll get. Be sure you download the Motor Driver Library from Seeed Studio. Just go to their website and search for the motor shield V2 and you'll find the link to the correct wiki and then you'll find the link to download the motor library.
1. Practice with the Motor Driver code to make robot go different directions.
2. Review Ultra Sonic Sensor code from previous projects.
3. Final Robot Code
Once you've experimented with movement and direction and understand how an Ultrasonic Sensor work, follow the Fritzing Sketch to wire everything up correctly. Also use the pictures provided. Then copy or type in the code below that combines the motor driver code with the Ultra Sonic sensor code. Notice the important parts are the "if" and "else" statements. These tell the Arduino micro controller to make the robot go forward until it reaches an obstacle 10 cm away. Then turn right. if robot senses object at < 10 cm else turn right. The word "else" mean "then do".
After you copy code, make sure all connections are correct. Set up some obstacles. Attach batteries and give it a try.
You will notice that the robot stops after a few centimeters and then continues. Why? how can we eliminate that pause.
You will notice that the robot stops after a few centimeters and then continues. Why? how can we eliminate that pause.