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):

You will also need the following Arduino Software and Libraries. Instructions on how to download/install the IDE are provided in the link:

  1. https://www.arduino.cc/en/main/software
  2. https://learn.adafruit.com/adafruit-motor-shield/l...

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:

  1. 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).
  2. 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.
  3. 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

Once you have the RC Car stripped; add your Arduino, Motor Shield, Breadboard, and pantilt servo. I would suggest not permanently gluing it to the Car right now, as you may need to make change or tweaks to your layout after testing your car. You may have different materials which is fine, but keep in mind that the PanTilt servo will be moving, so keep all the wires away from its surroundings.
Here you can also work on creating the structure of your RC Car, maybe some defense on the sides or protection for when the car hits a couple walls.
Also, keep in mind of the tilting right/left tires for when you are cutting your cardboard base out to place on the car.

Step 3: Wire It!

Now its time to wire the motors, servos, and sensors

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. (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:
https://docs.google.com/document/d/1eXzPpJqMhSi0rG...

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.

Tips:

  • 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!

Enjoy!
Feel free to ask any questions in the comments below.