Introduction: Autonomous RC Car (Wall-E)
We have created this page as part of our final project in Robotics at Mount Royal University. My partner and I will go through instructions on how to create your very own Autonomous RC Car from Scratch. We will provide all the steps and code necessary.
To begin, you will need the following materials (Click on any of the materials to see where you can buy it):
- 1x Arduino Board
- 1x AdaFruit Motor Shield
- 1x Ultrasonic Sensor
- 1x Pan-tilt servo
- 1x RGB LED Light
- 1x 9V Battery with connector
- 4x AA 1.5v Batteries
- 1x Small Bread Board
- Female to male wires
- Other Wires Double-sided Tape Paperboard
You will also need the following Arduino Software and Libraries. Instructions on how to download/install the IDE are provided in the link:
Step 1: Strip the RC Car
Purchase a used RC Car, or use one at home that you lost the remote for. You will need to strip down the car and remove all its components except for the wires. There are 2 (maybe 3) sets of wires that are crucial for you to keep intact:
- Power wires
- There should be 2 wires coming out from by the power supply of the Car. One will be for the positive end (sometimes its red) and one for the negative end (sometimes black).
- Motor wires
- There should be 2 wires also for the motor, one for positive and one for negative. You can test which ones are for the motor by using a 9v battery and connecting the wires to it. The motor will spin.
- Second Motor (Optional)
- Not all RC Cars have this, but if your RC Car has moving front tires then there would be a second motor. This motor will tilt your tires left and right. Test it out with the battery!
Step 2: Build the Foundations
Step 3: Wire It!
Now its time to wire the motors, servos, and sensors
- Connect your PanTilt Servo's to the Servo slots on the motor shield. These are the special pins that are allocated for two servos. The pins used are Pin 9, and 10, so make sure you don't use those pins for other parts.
- Connect your motor's to the motor slots on your shield, these are the large blue pins (use a screw driver to open the slot and then tighten your wire in). Take note of which motors you are using (M1-M4) for when you start coding.
- Connect the power supply of the RC Car to the power on the motor shield. This will be next to the motor pins, and its the smaller blue pins. If your RC Car does not have a On/Off button, i would suggest creating a basic switch with the wires so that your motor is not constantly On.
- Connect the sensor, we used the female to male wires as it was much easier while sticking it on to the servo. Make sure you connect the Trig and Echo pins correctly on the sensor to the correct pin as shown in the code.
- (Optional) Connect an RGB light to any of the free pins. We used this for changing the light color (Green/Red) for when the car was reversing and going forward.
Step 4: Code It & Finish!
Take a look at the code that we have uploaded. The Arduino .ino file is also uploaded into the compressed folder. If you are having a hard time downloading the entire project, or just want to check out the code only; Here is a link to just the code:
Copy and paste the code into your Arduino IDE. Make tweaks as needed based on your wiring. There are comments within the code to help explain what they are used for and how it works. You are free to make any changes and modifications as needed.
- You may need to adjust the speed within the code depending on how fast/slow your car is going. If the sensor is not quick enough, try setting the speed a little slower.
- Tweak the sensor "maximum range" variable as needed. This sets the range for the sensor, if the sensor comes within range of an object then it will reverse.
- Changing the tilting position of the servo is also important. Depending on how high or low your car is, and where you decided to put your servo, you may need to change the tilting angle accordingly.
- Finally, the "loop" function is where all the actions happens. Tweak it as needed or leave it the same. We found a Case Statement works best for this project!
Feel free to ask any questions in the comments below.
We have a be nice policy.
Please be positive and constructive.