2012-12-28T07:59:28Z

Building an Arduino Robot, Part I: Hardware Components

Posted by Miguel Grinberg under Robotics, Arduino.

Arduino Robot

I have been doing software for almost as long as I have memory. I have also been following the open source hardware movement since its inception a few years ago, but I have never found the time or the disposition to attempt a hardware project myself.

Until now, that is.

I have decided to do a small hardware project to get my feet wet, a project that I will fully document and discuss here with the hope to encourage and motivate others to do the same.

Here is the list of articles I have published:

Deciding what to build

For the hardware platform I have decided on the Arduino. This was an easy choice, as this is a platform that is widely used by hardware tinkerers all over the world, which means there is plenty of information and resources available.

The choice of a project that is in line with my (limited) knowledge was also pretty easy to make. I knew I wanted to build a cool toy, something I can impress my kids with. That pretty much reduced the list of options to just one: a robot.

But what kind of robot? A humanoid robot would be awesome to build, but it does not seem like a good choice for a first project. I needed something easy enough that I can complete in a relatively short amount of time, yet hard enough to be interesting and challenging.

After some Googling to see what other people do with Arduinos I have settled on a remote controlled robot vehicle.

As I said before I wanted to make this challenging, so I decided against buying a kit that includes all the parts, the software and the instructions. Instead, I decided to come up with a relatively custom robot design, get the parts I needed and figure out how to build it and program it without any specific instructions.

Here are the features I decided my robot will have:

  • It should be a vehicle that can move forward, backwards and turn.
  • It should be easy to assemble and disassemble.
  • It should have a mode in which it is able to move on its own, detecting obstacles ahead and avoiding them.
  • It should have a mode in which it can be fully controlled from my Android smartphone.
  • It should be easy to hack, change and improve.

Does this sound interesting enough to you? I hope it does, it certainly does to me!

Shopping list

With the above feature list in hand I went on to research what parts I needed for my project. Here is the list I came up with:

  • Arduino board
  • Motor controller
  • Distance sensor
  • Bluetooth slave
  • Prototyping board and cables
  • USB cable
  • Vehicle kit

The Arduino board

Arduino Robot

The Arduino board will be the brain of the robot, as it will be running the software that will control all the other parts.

My son had an old Arduino Uno that he ended up not using, so I did not need to buy one. There are plenty of Arduino models or even Arduino compatible boards that can be used.

My recommendation: Arduino Uno R3, currently $21.95 at Amazon.

The motor driver

Arduino Robot

The Arduino board cannot directly control a motor. The tricky part is to be able to make the motor selectively run forward or backwards, which requires swapping power and ground inputs into the motor.

There is a specialized circuit called an H-Bridge that can do this, and there are several implementations of this circuit readily available for the Arduino platform, or you can also build one from basic parts for next to nothing.

Without having much knowledge about this I bought the cheapest motor controller board I've found, a fully assembled version of the Adafruit motor shield at Amazon for $13.99. Later I realized with this board I will need to work around a design issue, so if I had to buy again I would get a more expensive one. More about this later.

My recommendation: Arduino Motor Shield R3, for $33.01 at Amazon.

The Distance Sensor

Arduino Robot

Distance sensors send an ultrasonic signal forward and then wait to receive a bounced signal. Depending on how long the signal takes to bounce back the approximated distance to an obstacle can be calculated. I will use this little device to prevent the robot from hitting walls or other obstacles in its way.

Browsing on Amazon I found a cheap and highly regarded component, the HC-SR04, currently selling for $6.59. This is a nice component that will not only give the robot the ability to see but also give it cool looking eyes!

My recommendation: HC-SR04, for $6.59 at Amazon.

The Bluetooth Slave

Arduino Robot

The easiest way to control the robot from a smartphone is via the bluetooth serial interface that all modern smartphones have. The phone will act as a master, so I needed a bluetooth slave for the robot.

Browsing on Amazon I found the BT2S Bluetooth to Serial Slave which seems to fit the bill nicely.

My recommendation: BT2S Bluetooth to Serial Slave, for $14.95 at Amazon.

The Prototyping Board and Cables

Arduino Robot

Arduino Robot

One of the restrictions I decided to impose myself with this project is that I would not do any soldering, so that I can assemble and disassemble the robot to my heart's content without ruining any parts.

Then I needed a platform where I can easily connect all the components together. For this kind of task people typically use a breadboard. Browsing on Amazon I found one from microtivity that comes with a set of jumper cables.

My recommendation: microtivity IB401, for $8.66 at Amazon.

The USB Cable

Arduino Robot

The Arduino board is connected to a computer via a USB port. The USB connection is used to upload software and also can be used as a power source when testing.

I took a cable from an old printer I have, so I did not need to buy this item. If you need to buy a cable, make sure you get the right connectors. The computer side is the standard A-Male, but on the Arduino side you need a B-Male connector.

My recommendation: Amazon Basics USB 2.0 A-Male to B-Male Cable, 6 feet for $5.49 at Amazon.

The Vehicle Kit

Arduino Robot

There are many choices for robot friendly vehicles. My only requirements were that it had a large platform where all the parts can be mounted and that it came with the wheels and motors.

In the end I decided to get the Magician Chassis. This is a kit that is extremely simple to build. It includes two motors and a battery box that plugs directly into the Arduino board.

My recommendation: Magician Chassis, for $25 at Amazon.

The total cost for the parts above gets to around $115 if you go with my recommendations, but if you want to save money you could certainly spend less and do more work.

Final words

Thank you for reading the first part of my tutorial series, I hope you found it useful.

In the second article I will fire up my Arduino board, introduce you to the Arduino development environment and finally write a few little Arduino programs to demonstrate how to control each of the parts of the robot.

If you have any questions or comments please write then below and I'll do my best to address them.

See you next time!

Miguel

113 comments

  • #76 kelvin danford said 2015-07-07T23:11:56Z

    thanks for the tutorial...bt am the beginner can i to build my robots without any knowledge in arduino

  • #77 Miguel Grinberg said 2015-07-08T02:23:35Z

    @kelvin: I think you need to start from something simpler, so that you familiarize with the Arduino hardware and how to program it.

  • #78 Duncan said 2015-07-09T02:58:19Z

    Hey Miguel, I really want to try this but I noticed the chassis has been discontinued.. If I purchase this one: http://www.amazon.com/gp/aw/d/B00GLO5SMY/ref=mp_s_a_1_2?qid=1436410420&sr=8-2&pi=AC_SY200_QL40&keywords=arduino+car+chassis&dpPl=1&dpID=51pvTZ%2B-E6L&ref=plSrch

    Will it require new code because of different motors or will there be no problems other than fitting everything on the chassis? Thanks

  • #79 Duncan said 2015-07-09T03:12:29Z

    Hi it's me again. It appears as if the link I added doesn't have an axel. This means the omg way it will turn is if one wheel moves while the other pivots. Will this affect the Cordero is that how yours worked as well?

  • #80 Miguel Grinberg said 2015-07-09T05:07:06Z

    @Duncan: looks like a close enough model. As long as you use the same motor driver I think you'll be able to use the code as is.

  • #81 Miguel Grinberg said 2015-07-09T05:10:50Z

    @Duncan: you can actually make the car turn in place by moving the motors one forward one reverse, that's what the software does. Should work on this kit you have as well.

  • #82 Carlos said 2015-07-13T21:38:19Z

    thanks! Great work!

  • #83 alex said 2015-09-08T07:58:31Z

    Great! I have finished it,Thanks Migue!

  • #84 Dr Know not said 2015-09-30T07:24:29Z

    The Ardunio motor drive shield is useless really,as one it don't put enough current to drive anything bigger than a matchbox,,and also there is no software library for it either,which makes programming it to do anything other than the most basic functions very hard..I have tried to write a library for it,and everything seemed fine but when i added it to a simple sketch nothing happened.I kinda tried to reverse engineer the AF motor library for the Adafruit motor shield,but its a bit complicated for me and i may try to write a simpler library for it one day soon.I The thing that makes it hard is that the Adafruit shield uses a shift register instead of a simple H-bridge pin to pin interface like the Ardunio shield does.I have to brush up on shift registers and study the data sheet for the 74hc595 to try and reverse engineer but it may be too hard !for me anyway. i consider myself an intermediate in C C++.

  • #85 karotu said 2015-11-06T23:12:25Z

    Hi, I have a L298N stepper motor driver http://www.aliexpress.com/item/for-Arduino-Electronics-Integrated-Circuit-L293N-Stepper-DC-Motor-Driver-Shield-Expansion-Development-Board-DIY/32314323324.html?spm=2114.031010208.8.34.OeBZKu Will this work in place of the Adafruit motor shield? Also, can it work with the library you are using? Many thanks, Karotu

  • #86 Miguel Grinberg said 2015-11-09T02:02:14Z

    @karotu: No, the L298N motor drive is not the same as the Adafruit motor driver. It is a more basic board, I believe there is no library for it, you have to work with the pins directly. Here is an example Arduino sketch that shows how to use this motor driver: http://www.instructables.com/id/Arduino-Modules-L298N-Dual-H-Bridge-Motor-Controll/step4/Arduino-Sketch-Example/. To use my code with it, you will need to write a new motor driver class that controls the motors accordingly.

  • #87 Thomas said 2015-11-22T14:49:07Z

    Is this Bluetooth module a direct substitute for the BTs-2 module you are using? Is this module functional with the Android app?

    http://www.amazon.com/KEDSUM%C2%AE-Arduino-Wireless-Bluetooth-Transceiver/dp/B0093XAV4U/ref=sr_1_cc_1?s=aps&ie=UTF8&qid=1448202175&sr=1-1-catcorr&keywords=BT2S+Bluetooth+to+Serial+Slave

    I am considering using servos for the robot. I'm not sure about changes needed in the software or circuitry.

    Your assistance is greatly appreciated!

  • #88 Miguel Grinberg said 2015-11-22T18:47:09Z

    @Thomas: looks pretty similar, but if you see the reviews, there are complains about lack of documentation. You may want to make sure you have documentation and/or code for it, I can't really say for sure that it'll work with my code.

  • #89 dipen rathod said 2015-11-27T11:21:19Z

    Great tutorial but i want to ask can we use the robomart L293D motor driver instead of the recommended one,there is a major price difference in India.(i am only 14)

  • #90 Miguel Grinberg said 2015-11-28T18:50:34Z

    @dipen: you will need to write a different device driver for the L293D, but it should work just fine.

  • #91 williamsalinas said 2015-12-01T06:55:37Z

    Great work. Thanks for the help @Migual. I have used NewPing library with the SRF05.

  • #92 Tochi said 2016-02-09T14:33:04Z

    @Migual, Great job on this! Do you know of any other motors and gear box that would be compatible with this setup without purchasing the Magician Chassis?

  • #93 Miguel Grinberg said 2016-02-09T22:52:26Z

    @Tochi: probably any DC motor that is within the specs of the Adafruit motor shield.

  • #94 Yavar said 2016-03-06T13:45:41Z

    Hello, Thank you for posting this info.My question is:What modifications do I need to do in order to run the rover that I am building with Arduino components. What I am building runs on a 12V DC system( Gear drives etc). My guess would be that I would have to use relays to switch the circuits on and off (that is,if 5V relays exist). What would you recommend? Regards, Yavar

  • #95 haziq said 2016-03-15T05:26:13Z

    Can i use the 2Amp Motor Driver Shield to replace the Arduino Motor Shield R3 ?

  • #96 Miguel Grinberg said 2016-03-15T05:50:28Z

    @haziq: if you write a driver for it, sure.

  • #97 rohit said 2016-05-04T19:43:39Z

    Hi Miguel Can I use HC-04/Bluetooth sensor in place of BT2S . Or I have to install new library completable with HC -04.is there any change in connections coz it has two extra pins(KEY and STATE).

  • #98 Miguel Grinberg said 2016-05-04T20:10:47Z

    @rohit: I do not know the HC-04. Did you look in its documentation? They likely give you instructions on how to connect and control it.

  • #99 Ishrak said 2016-12-11T14:46:55Z

    can i use Motor Robot Car Chassis Kit with Speed Encoder wheels and Battery Box instead of magician chassis?

  • #100 Miguel Grinberg said 2016-12-12T01:01:59Z

    @Ishrak: I've never seen one of those up close, but from the pictures it looks fairly similar, so my guess is that it will work just fine.

Leave a Comment