James - Your first Arduino Robot

FeaturedContest WinnerContest Winner
Picture of James - Your first Arduino Robot
For more Robotics Tutorials see my website here:
For awesome videos about robots and 3D printing go here:

Thank you so much everyone for voting for James in the Toy Contest! He got first place and I won a $500 Shapeways voucher! Expect to see more robot instructables from me in the future! :D

So you want to make a robot? Don't know where to start? How about you learn how to make a robot with me and make James!
James was made as part of a Robotics Class I teach to a few high school students.

I called him James in memory of my late Grandfather James Manning Edwards who passed away 14-3-2013. He loved teaching and helping kids and died doing what he loved, hopefully this James will carry on that legacy.
Remove these adsRemove these ads by Signing Up

Step 1: Gather your Components and Tools

Picture of Gather your Components and Tools
For this build we will be using the Arduino Uno with a Prototyping Shield. You could use whichever Arduino you want with its own Prototyping Shield or Breadboard.

If you are looking to buy this Prototyping Shield search on ebay for “arduino prototype shield uno” and you should see it. Alternatively you can buy a similar looking one from Core Electronics:

Step 2: Planning

Picture of Planning
On a piece of paper sketch out a rough sketch of the shape you want your robot body to have. It is always best to have an idea of what you want your robot to look like before you begin its construction.

Next you will want to sketch the shape of the robot body onto the protective sheet of the acrylic, this can be done easily with a pencil. If you do not have acrylic you could use; balsa wood, ply-board, foam-core, cardboard plastic containers or even food containers! You will also need to mark out where you want your servo to go. To cut out the hole for the servo drill four holes on each corner where you want to put the servo, this is to allow the blade of the saw to be easily maneuverered, preventing finger loss.

Step 3: Arduino Mounting Holes

Picture of Arduino Mounting Holes
The Arduino will be attached to the robot body using M3 screws and spacers so you will also mark where the mounting holes are on the Arduino so they can be drilled out. Once all of this has been done cut out the robot shape on a bandsaw, if you don’t have a bandsaw you can use a coping saw.

Step 4: Ultrasonic Mounting Bracket

Step 5: Drivetrain

If you would like to learn more about DC Motors and Servos and how to use them with Arduino watch my tutorial below:

Step 6: Checkpoint

Picture of Checkpoint
So far this is what my robot looks like.

Step 8: Wiring the Motor Driver

To learn more about the L293D Motor Driver Chip and how to use it with Arduino watch my tutorial below:

Step 11: Code

Here is some basic code to get you started. I strongly encourage you to edit it and make it better once you have learned how it works.
To make the use of the ultrasonic sensor easier I have used the new ping library.

Step 12: Finished!

Picture of Finished!

Upload the test code and that’s it! You have made your first robot!
super sam1 month ago
I love it
tannerg022 months ago
lluc13 months ago


Just finished the bot, works nice with the sonic and distance ranging detection. Would it be possible to put the code for continous rotation here. It would help me a lot. Thanks in advance.


za_tbr3 months ago
All good i figured it out myself cheers.
za_tbr3 months ago
Hi. Just wondering if you could upload the code to use the servo motors. This will help me immensely as I can then compare to see what I am doing wrong . Cheers
rafiulmollah3 months ago
plz send the codes without servo
rafiulmollah3 months ago
If possible send the codes without servo motor.
McClay143 months ago
Put ur robots on the hardware hacking contest, u could get 3d printer stuff :D
rshinosuke4 months ago
Thanks for the tutorial...
that's awesome...

but i found a mistake your basic code with your video in tutorial 4,
#define LeftMotorForward 6
#define LeftMotorBackward 5
#define RightMotorForward 8
#define RightMotorBackward 9
in your video LeftMotorForward and Backward was 10 and 11

mohamedshadir4 months ago
what is the use of this robot?
Real Abin4 months ago
how to build a Robot full detail
gabbas15 months ago
What Voltage do your motors run?

I got 2 3-6v DC Motors. If i power my motorshield with a 9V battery the motors are way to fast an start smelling..
chickenparmi (author)  gabbas15 months ago
Mine are actually 12V motors. A simple way to combat what you are having is to send a PWM wave to both the enable motor pins. This will essentially turn the motors off and on very quickly. You can do this with the analogWrite function. 255 being full on and 0 being off. Start off by sending a wave of 50% duty cycle (about 128), this will give you an average voltage of 4.5V. Also, I hope you aren't using a singular 9V battery, they do not have enough juice to power motors. I suggest getting a AA battery pack as they have much more juice and will run the motors safely.
@chikenparmi - I would like to ask the cost to build James. Thanks :)
chickenparmi (author)  katrinealbuera5 months ago
It really depends on how you want to do it. I would say maximum cost would be $100. That is the absolute maximum. It would more be around the $80 mark.
rudj006 months ago
I have encountered some problems, when I uploaded your codes
when it scan to the left and right it cant determine where will he go otherwise scan and scan repeatedly
chickenparmi (author)  rudj006 months ago
It's just one of those things. There could be a variety of factors why, such as power stability to the sensor, but it probably just is the fact that the code isn't all that great. The main thing I ask people to do is to learn the basics of what it does, then improve it. I'm by no means a programmer and everything I have learn't is self taught through trial and error.
simplebotics6 months ago
Why are you using an h bridge for servos?
chickenparmi (author)  simplebotics6 months ago
I'm not. I'm saying there is two ways to do this, you can use cont. servos or DC motors (with an H-bridge). The idea is I encourage people to muck around with the design and make it their own.
hi chickenparmi
i am new to working with arduino and its programming. i had a problem programming the arduino. when i click verify it compiles and say's that

OAR:17: error: 'NewPing' does not name a type
OAR.ino: In function 'void scan()' :
OAR:124: error: 'sonar' was not declared in this scope
OAR:125: error: 'US_ROUNDTRIP_CM' was not declared in this scope

i like your instructable and i want to make it. please solve my problem.
chickenparmi (author)  sanjay satheesh10 months ago
Oh I'm so sorry! Thats completely my fault. I forgot to mention that you will need to download and install the newping library. All this library does it make it easier to use the ultrasonic sensor. Here is the link:
And I will add it to the instructable also.
yuo dunot put code for png senzor in yo main code?
PipPipPia6 months ago
where did you find your L239D ? (also, is that the same thing as an integrated circut/motor driver ?) i can't find a 16 pin one anywhere online.
McClay148 months ago
where do you get the dc motors you are using, do they come with the gear box and wheels?
chickenparmi (author)  McClay148 months ago
The DC motors, Gearbox and Wheels I am using here were actually part of an old robot kit that you could buy bit by bit as part of magazines, it was called the Cybot. If you would like them specifically keep an eye out on ebay as they often appear with or without the Cybot base.
Jon Freeman8 months ago
Many thanks for this.  A really great instructable!!!

After working through The Arduino Starter Kit, I ended-up missing a good "final project" and James really fits-the-bill.  As an aside, it would not take much for Arduino to include it in the kit and add a good deal of value.

I have attached a picture of my James clone.  I used a Magician chassis from Dagu - otherwise it tracks your design. It may be worth mentioning that the Dagu-supplied geared motors draw a max of 250 mA each which is supported by the L293D (theoretically 600 mA per channel).  Unfortunately, the motors are not balanced - which means the robot will wander around in circles if you do not use PWM enablement to slow-down the stronger motor.

I also attached a Breadboard View which may help some of your readers with the wiring.

Finally, congratulations on winning the competition!!!  Well deserved.
chickenparmi (author)  Jon Freeman8 months ago
No worries! I am glad you liked it!

I found the same thing. I too bought an Arduino starter kit and soon ran out of things to do, you can even check my YouTube if you wish to see my earlier builds. Making a robot seemed like a nice challenge to do and I had some previous encounters before with robotics in my life. I learnt a lot and just continued making robots.

Your robot looks great! The problem you mention occurs 99% of the time and can be quite annoying and sometimes difficult to compensate for. The only really good way of dealing with it would be too add encoders for positional accuracy.

Thanks for that breadboard schematic! Looks great and easy to comprehend.

Thanks again!
This is a very cool robot.
I build small simple mechanical robots that don't look like a lot but they.

If you want to know more type in robug in 'lets make'

ps well done winning the contest.
makesomeso9 months ago
i like your robot very much. i am also going to make this.
chickenparmi (author)  makesomeso9 months ago
Thank you very much! :)
Hi Chickenparmi.
Nice instructable.
I'm new to working with motors and servos and I'm struggling to find a 180 degree servo on ebay / Amazon. Not many seem to mention the rotation angle but all seem to state something like 0.1sec/60' 4V does this mean the servo will only turn 60 degrees?
I only need to get the servo to complete this project.

chickenparmi (author)  mintyfreshpenguin10 months ago
What you're referring to is just the speed of the servo. What that effectively says is it takes 0.1 seconds to rotate 60 degrees.
Hope it all goes well for you.
dracorabbid10 months ago
This is a great tutorial. I would like to know whether the arduino sketch would change if I use two servos for the drive rather than two dc motors and an l293d chip.
chickenparmi (author)  dracorabbid10 months ago
I just made another robot instructable but this time using continous rotation servos,, the code for movement is there also.
chickenparmi (author)  dracorabbid10 months ago
Yes the code would change, but it would only be a minor change. Because I have all the movement operations in their own void functions all you have to do is change what happens in those voids and they will apply to the whole code. Continuous rotation servos, using the arduino servo library, move one direction full speed for a value of 180 and the opposite direction at full speed at 0. So to change the code all that needs to be done is delete the pin assignments for the h-bridge, 'attach' the two servos and just write the appropriate 'angles' in the movement voids. Let me know if this doesn't make sense and I will try to upload another version of the code using cont. rot. servos. Thanks for the comment.
Edgar10 months ago
Nice! :)
Voted, and went to my Blog:
chickenparmi (author)  Edgar10 months ago
Thank you very much! I'm glad you like it :D

Get More Out of Instructables

Already have an Account?


PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!