Autonomous Arduino Car




My questions for the Make-to-Learn Youth Contest :)

What did you make?
This goal of this project was to take commonly available electronic equipment and create an inexpensive, self-controlled vehicle. In simpler terms, this is an attempt at basic autonomy. It uses an arduino logic board coupled with a cheap remote control car along with a 9 volt power supply to accomplish this.

How did you make it?
The idea came to me while I was researching infrared sensors and light for a laser synth project I was planning. It seemed to me like a very viable technology for sensing objects, so after a little more research into motors and how I could control them with analog input, this project was born.

Where did you make it?
Without my school classes, I might never have done this. It was an assignment to come up with something cool involving computers, with a fair degree of freedom. I settled with an arduino-based project. Much of the programming and testing was done on the floor of my classroom, and the construction of the car in my bedroom. It took over my life for a week or two, all I was thinking about was bugs in my code and better methods of measuring and processing the infrared.

What did you learn?
Most importantly, the input of others is an invaluable source of ideas and solutions. Whenever I came to a halt in my production, a classmate might chime in and say something I had not previously thought of, like measuring the resistance across the car's motors to see if some object had stopped the car. This is one of the more challenging projects I have completed, and the first to really combine hardware and code, which I feel is a great accomplishment. Looking back, I could have used a bit more planning and done more research (rest in peace, poor LEDs) so that I had less issues. 

This car uses an arduino logic board to process the input from an infrared sensor at an attempt at very basic collision detection/prevention.

This project was only marginally successful. Do not attempt this with high expectations. The low-tech nature of the sensors are very inefficient ways of detecting objects, and in different environments may work better or worse with the code provided. This is only a general guide, modifications will be necessary to make the car work as intended depending on your choice of parts.

That being said, hopefully you're able to make it work a little better than I did!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: List of Parts

Important Stuff
Arduino Motor Shield*
RC Car**
Soldering iron
Infrared Emitter (IRED)
Infrared Detector
9v Battery with clip
Power switch

General Tools
Glue of some sort
Copious amounts of wire

*Note: If your car of choice contains a large controller chip, it is likely the TX2 or RX2 chip. If so, you can save a lot of money and use the motor controller built in to the car to control it. Techbitar provides a good tutorial for that here:

Step 2: Teardown

Your first step will be taking everything out of the car. Remove screws securing the body of the car to the chassis, then remove all circuit boards from the car. The motors should be left in their place, this projects only requires the chassis, wheels, and motors to function properly.

Step 3: Preparing the Sensors

It's time to begin preparing the electronics. To begin, solder a 100 ohm resistor to either lead of your IRED. Solder wires to the other end of the resistor and the other lead of the IRED.

Next, solder two lengths of wire to both leads of your IR Detector.

Check your motor wires, make sure each terminal of the motor has at least 4-5 inches of wire depending on the size of your car.

Step 4: Securing the Arduino and Sensor

After clearing some plastic off the chassis, I chose to use some small zip ties and holes in the chassis to hold my arduino to the car.

Next, you'll want to choose a location on the front of the car for your emitter and detector. You'll want to make sure they are level with the ground, and possibly consider adding heat shrink tubing around the emitter to prevent some light from hitting the detector before it reaches an object.

Another consideration would be to add another set of leds on the back of the car to avoid obstacles while backing, but are not included in this instructable.

Once you have glued your leds in place, go to the next step.

Step 5: Power Supply

This project will run off of a single 9v battery. Take your switch and solder one piece of wire to a pin, and the positive terminal of the battery to another pin.

After this, secure your battery with double sided tape, zip ties, or any other method you prefer.
Mine fit nicely into the cars original battery compartment.

To extend the life of the car you might also connect two batteries in parallel.

Step 6: Wiring

The provided diagram should make this very simple, but here is a list form of the pinout.

Note: The positive lead of an led is the longer leg. If you are unsure of which that is you should consult google about your particular led.

Pos - 5v
Neg - Ground

Pos - Analog pin 5
Neg - Ground

Drive Motor
Pos - Motor Shield Channel A +
Neg - Motor Shield Channel A -

Steering Motor
Pos - Motor Shield Channel B +
Neg - Motor Shield Channel B -

Pos - Motor Shield Vin
Neg - Motor Shield Gnd

Step 7: Programming

Given the dynamic nature of this project, it is very likely you will need to make many modifications to the code based on the size, shape, turning radius, speed, and weight of your car, as well as the ambient lighting of your testing environment (which I've attempted to compensate for).

int irsensor = A5;
int motorspeed;
int run = 0;
int measure = 1;
int ambientir = 0;
int distance;

void setup() {
  //Setup Channel A
  pinMode(12, OUTPUT); //Initiates Motor Channel A pin
  pinMode(9, OUTPUT); //Initiates Brake Channel A pin
  pinMode(irsensor, INPUT);
  digitalWrite(irsensor, HIGH);

void loop(){
  if(run == 0)
      ambientir = ambientir + analogRead(irsensor);
      measure = measure + 1;
    while(measure < 10);
    ambientir = ambientir / 10;
    run = run +1;

  distance = analogRead(irsensor);

  if(distance < ambientir - 50){
    digitalWrite(12, HIGH); //Establishes backward direction of Channel A
    digitalWrite(9, LOW);   //Disengage the Brake for Channel A
    analogWrite(3, 100);   //Spins the motor on Channel A at half speed
  if(distance > ambientir - 50){
    digitalWrite(12, LOW); //Establishes forward direction of Channel A
    digitalWrite(9, LOW);   //Disengage the Brake for Channel A
    analogWrite(3, 100);   //Spins the motor on Channel A at full speed

That being said, good luck. I think any programmer will agree, this will not work on your first attempt.

Step 8: Finishing, Testing, and Thoughts

I painted and secured the original body onto my car before I began testing.

Some of the problems I ran into:
Limited range of the sensor
Speed of the car (unable to quickly stop)
Ambient infrared light
Cheap Chinese plastic

It is possible, I think, to compensate for changing ambient light as the car moves around different environments, but testing that portion of the code would have taken longer than the time I had allotted to this project. The car does a very nice job of avoiding walls, but when it drives towards smaller objects (chair/table legs in my instance) it will frequently run into them because the range and spread of the two leds don't work well together on seeing smaller objects. This is likely also fixable with an increased number of emitters, a higher quality sensor, or clearing the room of obstacles. Another solution to this, which I have yet to complete testing, is reading the resistance across the drive motor when the car is stopped by an object. 

UP! Contest

Participated in the
UP! Contest

Make-to-Learn Youth Contest

Participated in the
Make-to-Learn Youth Contest

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    38 Discussions


    2 years ago

    Hi . Can it be done using tensorflow ?
    If you can do it i am ready to buy . But i need it very much


    5 years ago on Introduction

    Nice article! We built a similar project. However, we installed an Android device onto a RC car and used an IOIO board to control it autonomously. Here is the preliminary result:

    3 replies

    Reply 2 years ago

    Can you guys send me how you did that.


    Reply 5 years ago on Introduction

    You can find more details here:


    2 years ago

    Hey everyone,

    If you are looking for a fully assembled Arduino car (you don't have to assemble it at all), which includes all of the code for it to move and instructions on how to use it, program it, and develop it -

    go to:


    2 years ago

    Rather than avoid obstacles, could this be made to stop and start on a line?


    3 years ago

    I have a question about the steering motor part of the RC. What part of the programming affects the steering motor of the RC? It doesn't seem to specify what happens to B channel on the motor shield.


    4 years ago

    I have to make a wireless car with ultrasonic sensor,motion sensor,humidity sensor,gas sensor,wireless camera,light sensor etc is it possible


    4 years ago on Introduction

    This is actually the coolest thing i have ever seen, I quit my job the instant I saw this and dedicated the rest of my life to achieving the euphoria i experienced watching u make this extraordinary work of art. I thank you good sir, you have made my life worth living.


    5 years ago on Introduction

    Do you possibly have a schematic to follow? I'm having trouble following the pictures.

    do I have to use the 9v battery or could I use this 6.7v lithium battery that came with the car


    6 years ago on Introduction

    you should try to add a few more infrared around the car to increase the accuracy of the length between walls and do more math on the turning part

    2 replies
    absolute zerodeqwer

    Reply 6 years ago on Introduction

    I had considered that, unfortunately time and finances were some limiting factors in this project. The turning function has been improved today, but it still contains bugs. It now will read the resistance across the motors to tell if the car has backed into an obstacle. I also added a little function to calculate the distance the car has traveled, and incorporated random numbers from the noise on unused pins to have the car take different paths instead of going in a straight line.

    Thanks for your input!

    vgruenabsolute zero

    Reply 5 years ago

    Hello !
    I have to build myself a self-driving rc car for a school project and I believe that I will use an apporach rather similar to yours. Sadly I do not have much experience at all with the arduino or how you program it. I know that I am almost a year to late but do you think you could give me some help ?