Autonomous Arduino Car





Introduction: 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!

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. 



  • Remote Control Contest 2017

    Remote Control Contest 2017
  • Arduino Contest 2017

    Arduino Contest 2017
  • LED Contest 2017

    LED Contest 2017

We have a be nice policy.
Please be positive and constructive.


Questions & Answers


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

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:

Can you guys send me how you did that.

hi, do you mind to share more detail of your work?

You can find more details here:

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:

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

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.

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