Intro: Arduino Obstacle Avoidance Robot (NEW SCHEMATIC)
In this project, we will be making an obstacle avoidance robot using the Arduino Uno. This robot is designed to move around and avoid any obstacle it encounters using an ultrasonic sensor. For those who needed a schematic diagram, I have added it for visual learners.
- 1 Arduino Microcontroller- http://www.robotshop.com/en/arduino-uno-usb-microc...
- 2 Parallax Continuous Rotational Servos- http://www.robotshop.com/en/parallax-futaba-contin...
- 1 180 Degree Hi-Tec HS-422 Servo- http://www.robotshop.com/en/hitec-hs422-servo-moto...
- 1 Pack of Jumper Wires- http://www.robotshop.com/en/65-22-gauge-assorted-j...
- 1 Breadboard- http://www.robotshop.com/en/sfe-mini-170-solderles...
- 1 Tamiya Track Kit- http://www.amazon.com/s/ref=nb_sb_noss_2?url=searc...
- 1 A to B USB Cable- http://www.robotshop.com/en/usb-cable-a-b-arduino....
- 1 Parallax Ping))) Sensor- http://www.robotshop.com/en/parallax-ping-ultrason...
- 1 Barrel Connector Battery Case- http://www.robotshop.com/en/adafruit-9v-battery-ca...
- Pin Jumper Wires- http://www.robotshop.com/en/300mm-f-f-20-pin-jumpe...
- Arduino Program
- Your Hands
- Hot-Glue Gun
- 9 Volt Battery
Step 1: Step 1: Servos
The first step is to make sure your servos are working. For the Parallax continuous servos, use the jumper wires to connect the black wire to GND, red wire to 5V, and the white wire to digital pin 9 on the Arduino. For the Hi-Tec servo, the only difference is that the signal wire for the servo is yellow, compared the the white wire on the Parallax servo. After, just upload the sweep code that I have uploaded for you at the bottom of the page.
Are your servos working? If it does, good. If not, then go get a refund from your supplier. Now that your servos are working, it is time to center them. This will ensure that your servos are well balanced and even. I have provided you with the code file below.
After you have uploaded check to see if your servo moves. If it doesn't, don't freak out because that's good news. You're all set. If your servo does move, use a Phillips screwdriver, and slowly turn either way in the tiny slot to adjust until your servo stops moving. After you are done, you are ready for the next step. Yay!
Step 2: Step 2: Ping Sensor
Now, you are ready to test your Ping))) sensor. First, connect the GND pin on the Ping sensor to the GND on the Arduino. Then connect 5V pin on the Ping sensor to the 5V slot on the Arduino. Lastly, connect the SIG pin on the Ping sensor to digital pin 7 on the Arduino. After that, upload the code onto the Arduino and go up to tools, and open up serial monitor. A window will open, and it will show you the sensor's distance from an object in front of it. Congrats! You are done testing the Ping))) sensor!
Step 3: Step 3: Attaching the Servos
This is the fun part! You will now be completing the hardware section of your project. First, you will have to assemble the Tamiya track kit. If you want, you can assemble the whole thing, but the thing you really need to assemble are the 2 tracks and the rest of the wheels. You will notice that the wheels with teeth do not have a free moving axle, but a gearbox instead. You do not need to assemble or even use the gearbox! Save the parts for other projects because we only need the 2 wheels with teeth. First, you will have to cut the plus signs that comes with your continuous servos. Just cut half way down, about 2 holes from the center, enough to fit it into the Tamiya wheels. After you are done doing it to both servos (ONLY THE CONTINUOUS ONES), hot glue the wheels the the servos. Now, place the servos with the bottoms touching each other, sides facing down, and the long part pointing out, or else your robot will run backwards. Then attach the sensor servo (180 degree servo) straight up with the long side pointing back. You can use hot glue, velcro, or tape to attach the servos down to the base (I used velcro, but anything will work). Now using the breadboard, connect the servos to the 5V port and both to a common ground (GND). Also connect the servos to the right digital pins. Then attach the battery box between the continuous and 180 servos and stick the breadboard on top of the battery box.
Step 4: Step 4: Connecting the Sensors and the Rest
Now the servos are done, Its time to connect the Ping))) sensor. First, you must attach the Ping)) sensor onto the servo. I glued 6 Styrofoam meat trays cut into squares on top of each other to make a block. You can do the same, use cardboard, or just purchase a block of foam. I do not recommend gluing the sensor directly to the block, but instead use pins, or nails to pin the sensor to the block. Then, I used tape to secure the Ping sensor onto the block. After that, I stuck the breadboard on top of the battery pack (the breadboard was really small) and the Arduino onto both of the continuous rotational servos.
Step 5: Step 5: Finishing Touches and Coding
Yay! This is the final step! Now, connect the arduino to your computer and paste in this code into your Arduino program and install it into your Arduino (make sure you verify the code, just in case). I give credit for this code to Brandon Campbell. Check out his YouTube videos because he got some really awesome videos and tutorials (this Instructable was based on this code, and since he didn't give a tutorial I decided to give one myself).
After that, plug in the power pack into the smaller plug onto the Arduino, turn it on, and watch your robot go! If it does not go, feel free to ask me in the comment below, or through my email. I will try my best to reply as soon as possible and thanks for reading this Instructable! If you like this, please follow me for more fun projects like these and I will see you again!