An autonomous car

A couple of years ago I bought the chassis for a tiny car. It lay dormant for a while but a couple of weeks ago suddenly something lit my spirit and I build it into a autonomous driving vehicle.
Its purpose: driving around, entertaining the kids and scaring the cats. It just drives around, avoiding collisions.

It consists of:

Now building this is trivial. Connect the motors to the shield, add 3 distance sensor on the left, front and right side and stick the compass somewhere on it (but not too close to metal - it'll confuse the thing I noticed).
The thing is powered using two LiPo batteries. One for the motors, one for the brain (the Arduino). The ones I bought output 12,6V so I bought two DC-DC converters which convert that into 5V.
For fun I added two NEO pixels that show what direction it is moving.

The next part is the software. If your only goal is letting it drive around, avoiding obstacles then that is also almost trivial:

  • drive forward
  • continue until the front sensor sees that we're about to collide in a wall
  • move backwards a bit (not more than what you moved forward in the first step - I pick the duration for that)
  • check if we can move left, or if we can move right
  • rotate until we're facing either left or right (that's what the compass is for)
  • go back to step 1

Arduino source code: karretje.ino.xz


  • Arduino pin 13: two Neo-pixels that indicate (using color) in what direction the car is driving
  • Arduino pin A0: sharp sensor looking forward
  • Arduino pin A1: sharp sensor looking left
  • Arduino pin A2: sharp sensor looking right
  • Motor shield address: 0x61
  • Motor shield motor 1: back left
  • Motor shield motor 2: back right
  • Motor shield motor 3: front right
  • Motor shield motor 4: front left



Other projects: here and here.

The Lotter allows you to participate in lotteries from all over the world!