Introduction: Ard-e: the Robot With an Arduino As a Brain

How to create an open source Arduino controlled robot for under $100.

Hopefully after reading this instructable you will be able to take your first step into robotics. Ard-e cost about $90 to $130 depending on how much spare electronics you have lying around. The main costs are:
Arduino Diecimella- $35 https://www.makershed.com/ProductDetails.asp?ProductCode=MKSP1
Bulldozer kit- $31 http://www.tamiyausa.com/product/item.php?product-id=70104
Servo- $10 I got mine at a local hobby store
Worm gear Motor- $12 http://www.tamiyausa.com/product/item.php?product-id=72004
Various other Electronics- around $10 radioshack or digikey.com
Sensors- anywhere from 0 dollars to $28 depending on how many you want and how extensive your pile of junk electronics is

So with spending around $100 you get a remote control robot with a pan and tilt system that could be used to aim a camera, a hacked airsoft gun ( http://inventgeek.com/Projects/Airsoft_Turret_v2/Overview.aspx ) or you could attach a laser to it because thats what you have lying around. If you wanted to be really cruel you could attach a dvd laser to it and burn whatever you wanted ( http://www.youtube.com/watch?v=CgJ0EpxjZBU )

In addition to making the pan and tilt system that is remote controlled you can also buy about three dollars worth of chips, attach sensors to Ard-e and make him fully autonomous. For around a hundred dollars you can build your own robotics system that has most of the functionality of a roomba or a lego-mindstorms robot: It can sense when it bumps into something be programmed to avoid what it bumps into, it can follow the brightest light, smell pollutants, hear sounds, know precisely how far it has gone, and be controlled by an old recycled remote control. All of this for about half of the price of commercial units.



This is my entry into the RobotGames robot contest so if you like it make sure to vote for it!

Note- Originally I was going to enter the remote controlled version only as my entry to the contest but since the deadline was pushed back Im gonna show you how to make Ard-e run himself.

So on to how to build Ard-e

Step 1: Build Your Bulldozer

So once you get your new bulldozer kit either in the mail or at your local hobby shop you have to put it together. These kits from Tamiya tend be a little on the expensive side but they are worth it. I found the worm gear box that I use to pan the laser in a box of old projects covered in dust, it hadnt been touched for maybe three years. After blowing off the dust and hooking it up it ran fine.

A pocket knife or leatherman should be all the tools you'll need to set up the bulldozer. The instructions are step by step and easy to follow even if the English is a little shaky. Since I wasn't planning on using Ard-e as a really weak bulldozer I didn't attach the plow.

The dc motors that drive the bulldozer are controlled by the double pole double throw (DPDT) switches that make up the controller. I added a diagram about how to hook up your own DPDT switch to control a motor because I later end up controlling the panning motor with another DPDT switch. Hopefully the diagram makes it clear that the switch when thrown one way makes the motor turn one way and when thrown the other it turns the other way.

Step 2: Assemble the Pan and Tilt System

So you now have a base for Ard-e that is engineered and constructed well (hopefully the English in the instructions didn't throw you off too much). Now you need to build something that this base can drive around and do cool stuff with.

I chose to put another DC motor and a servo on it as a pan and tilt system that could be used to aim whatever you wanted. The servo is controlled by the Arduino and the panning motor is controlled by a DPDT switch that I bought at radio shack for around two dollars.

To control the servo I wrote some code in the Arduino software environment that reads the voltage drop off of a potentiometer and converts that to the angle that the servo should be moved to. To implement this on the Arduino you hook the servo data wire to one of the digital output pins on the Arduino and the plus voltage wire to 5V and the ground wire to ground. For the potentiometer you need to connect the outer two leads to +5V and the other to ground. The middle lead from the potentiometer should then be connected to an analog input. The potentiometer then acts as a voltage divider having possible values of 0V to +5. When the Arduino reads the analog input it reads it from 0 to 1023. To get an angle to run the servo at I divided the value that the Arduino was reading by 5.68 to get a scale of roughly 0-180.

Heres the code that I used to control the tilt servo from a potentiometer:

#include <Servo.h>

int potPin = 2; // selects the input pin for the potentiometer
Servo servo1;
int val = 0; // variable to store the value coming from the potentiometer

void setup() {
servo1.attach(8); //selects the pin for the servo
}

void loop() {
val = analogRead(potPin); // read the value from the potentiometer
val = val / 5.68; //convert the value to degrees
servo1.write(val); //make the servo go to that degree
Servo::refresh(); //command needed to run the servo
}

If you need help working with the Arduino like I did then I highly suggest going to www.arduino.cc Its a fantastic open source website that is really helpful.

So after testing the control of the servo and the switch I needed a place to put them. I ended up using a piece of scrap wood cut to about the same length as Ard-e and screwing it into the back board with a piece of aluminum bent at a 90 degree angle.

I then installed the DPDT switch and the potentiometer into the controller. It was a tight squeeze and I had to drill another hole in the top of it to run wires out of but overall it worked out pretty nicely. I also ended up soldering wires onto the existing controller circuitry to power the worm gear box.

I really probably should have used another servo for the panning but the hobby store I went to only had one of the ten dollars ones and the motor can turn 360 degrees unlike the servo. The motor is a little too slow though.

Now on to testing.

Step 3: Testing and Making the Remote Controlled Version of Ard-e

So before we start driving Ard-e we need to make the Arduino mobile. All that you need for the Decimilla to become mobile is a 9 volt battery connected to a plug that fits into the external power supply. I ended up cutting the power cord from an old transformer and got a nine volt batter clip by taking apart an old nine volt. The jumper also needs to be moved from the usb power to the ext power. If the battery is hooked up correctly the power light on the Arduino should light up. If not you probably got the polarity wrong and should switch the wires. I did this at first and it didn't cause any damage to the chip but I would not recommend doing it for long.

Now you should test to see if everything is working as you expected. Attach something to the pan and tilt system like a camera or led. I used a laser zip-tied to the servo because it fit nicely and I had one laying around. Drive Ard-e around and try to not shine the laser into your eyes.

When I first put Ard-e together I put the Arduino behind the controller and taped it in place. With this set up every time I ran either the driving motors or the panning motor the servo would go to the 0 degree position. Apparently the running of the motors would interfere with the timing control pulse and make the servo think that it was supposed to be at 0 degrees. I figured this probably was because of how long the control wire on Ard-e's servo was. It had to the run from Ard-e to the Ardunio behind the controller all the while being in close proximity to the wires carrying the current to the motors. These wires induced alot of noise into the control wire and made it go to 0.

To fix this problem I moved the Arduino from behind the controller to on Ard-e. Note the very professional looking duct tape mounting of both the servo and the Arduino. This eliminated the motor wires inducing noise and fixed the problem. The long wires then just carried the power to and input signal from the potentiometer instead of the power and control signal for the servo. The noise from the motor wires now affects the reading of the potentiometer which has little to no effect on the degree that the servo is driven to.

So you now have the remote controlled version of Ard-e. Basically you just made a really cool home built car that you can drive around and point at stuff with. The Arduino is underused to say the least. Ard-e right now is using 1/6th of his ability to sense the analog world and 1/14th of his digital I/O capabilities. You could save yourself some money and just take out the servo and Arduino if a home built car is all you want.... But if you want to really sink your teeth into robotics read on about how to make Ard-e drive himself.

Step 4: Ard-e on Auto: Using the Ardunio to Drive the DC Motors

So if you wanted to use the Arduino to control the motors you cant just hook them up to one of the output pins because the Arduino wont supply enough current to drive them. To use it to drive them you need to buy a motor driving chip or a motor shield for the arduino. http://www.ladyada.net/make/mshield/ has one for $20 or you can just buy the chips that she uses from digikey http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=296-9518-5-ND . The chip that is commonly used is a L293 or other similar H bridge motor driver chip. This site has the pinout of it and some details about running a program on it http://www.me.umn.edu/courses/me2011/robot/technotes/L293/L293.html

The chip basically takes three inputs, one PWM input that sets the speed of the motor and turns it on and off and two inputs that determine the direction that the motor spins. The PWM pin is the Enable of the L293, the two pins that determine the direction of the motor spins are the Inputs 1A and 2A. The motors are connected to the outputs 1Y and 2Y. The L293 can control two DC motors so once you get it hooked up to the Arduino Ard-e can drive himself.
The data-sheet for the L293 can be found at http://www.datasheetcatalog.com/datasheets_pdf/L/2/9/3/L293.shtml

I ended up ordering two of the L293 chips from www.mouser.com and they cost me about $7. After a few hours of trial and error I finally got the Arduino to drive both of Ard-e's motors. I didn't read the data-sheet carefully enough because I originally was using 3V to try and run the L293 when it obviously (now at least its obvious) needs at least five volts. So after numerous trips to www.Arduino.cc here is the code I used to test drive Ard-e's motors:

int diraPin = 10;
int dirbPin = 9; //These two have to be opposite digital values to spin the motor if they are both HIGH or both LOW then the motor is actually braked.
int enablePin = 11; //This pin sets the speed of the motor and needs to be a PWM pin.
int dira2Pin = 2;
int dirb2Pin = 3;
int enable2Pin = 5; // These are used in the same way to drive the second motor.
int val = 0; // Variable used to set the speed of the motors.

void setup() {
pinMode(diraPin, OUTPUT);
pinMode(dirbPin, OUTPUT);
pinMode(enablePin, OUTPUT);
pinMode(dira2Pin, OUTPUT);
pinMode(dirb2Pin, OUTPUT);
pinMode(enable2Pin, OUTPUT); // Declares all of the pins as outputs.
}

void loop() {
val = 175; //A value used for setting the speed of the motor, about 70% of its speed.

//Spin motor 1 backward for one second
analogWrite(enablePin, val); // Set the speed of the motors with PWM
digitalWrite(diraPin, LOW);
digitalWrite(dirbPin, HIGH);

//spin motor 2 backward for one second
analogWrite(enable2Pin, val);
digitalWrite(dira2Pin, LOW);
digitalWrite(dirb2Pin, HIGH);
delay(1000); // If you switch which direction pin is high and which is low the motor will spin a different direction.

//spin motor 1 forward for one second
digitalWrite(diraPin, HIGH);
digitalWrite(dirbPin, LOW);

//spin motor 2 forward for one second
digitalWrite(dira2Pin, HIGH);
digitalWrite(dirb2Pin, LOW);
delay(1000);

// stop for a second
val=0;
analogWrite(enablePin, val);
analogWrite(enable2Pin, val);
delay(1000);
}

So to test this out on Ard-e I ended up putting a breadboard onto the addition that had previously held the pan and tilt system. I also moved the Arduino right next to the breadboard for easy prototyping. I also had to add another two AA batteries so the the L293 would have the 6V it needs to power the motors.

Heres a quick video of Ard-e running this program. One of the motors spins faster than the other so he veers towards the camera near the end of it. I don't really know why this happens...


So once you write all of the code and rearrange the components to make the Arduino boss around the L293 and get those pesky DC motors under control Ard-e's possible uses increase dramatically. All you need now are some sensors.

Step 5: Making Ard-e Sense the World With Junk

So once you get Ard-e's DC motors controlled by the Arduino you can make Ard-e into a truly autonomous robot that is no longer tethered to a controller.

Like any autonomous robot though Ard-e is gonna need to have sensors so it can interact with its environment. Where are you going to get these sensors you ask? Your old pile of electronics junk that any maker has.

Ard-e should at least have all the basic senses that we humans have right? How are robots going to take over the world if they cant see or touch things?? Well at least four of the senses, since robots don't eat anything other than batteries i doubt they will need a sense of taste. So if you have a very extensive pile of junk electronics you can make Ard-e have these four senses with just a bit of recycling. If your junk pile isn't humongous then a few trips to radioshack and maybe a few orders from digikey or mouser should fix that.

One of the most important senses for Ard-e to have is touch. Ard-e needs to know when he runs into something, and an old mouse that just about everyone has laying around is perfect for harvesting the push-button switches that he needs to accomplish this. After opening up the mouse you merely unsolder the switches and solder some wires on in place. Careful with this step though... I melted one of the switches by holding the soldering iron on it for too long. To make these switches into a touch sensor for Ard-e I used a piece of scrap metal bent into a bump switch that can tell if Ard-e hits something on his right side or his left side. The metal is easy to work with and if you fold it over itself as you make the shape you need it becomes pretty strong. The pictures will hopefully help with this step.

To interface these switches with the Arduino so Ard-e can react when he bumps into something I ended up using them as a voltage divider to an analog input pin on the Arduino. I'm sure it would be just as easy to use them as digital inputs but I just could not write a program to get them to work as digital inputs. Im probably overlooking something really simple but whatever.

Heres a short video of Ard-e running into two obstacles (my fingers), if he hits it on his right side he will reverse turn to the left and go forward. If he hits it on his left side he will reverse turn right and go forward.



Ard-e now has the sense of touch! Now onto sight.

Step 6: Making Ard-e See, or at Least Go Towards the Brightest Light

To make Ard-e have the sense of sight all you need is a few light sensors. I bought a pack of cadmium sulfide photocells from RadioShack for like 3 dollars. A lot of night lights have these that you can steal and the little outside solar lights are possible sources of these photocells too. I didn't have any of these laying around so I bit the bullet and bought them.

So these photocells change their resistance from around 10K to 100K ohms. I made up a little excel spreadsheet to figure out the possible values it would output if i hooked it up as a voltage divider. I got around 30K as providing the greatest difference from high resistance to low. I found some 39K resistors and figured they would work fine.

I just stuck them into the breadboard bent them forward and started testing out programs to make it seek out the brightest light. I ended up writing a program that reads the value from both sensors and if they are different by 8 it turns towards the one that is reading a higher value of light hitting it. I also used the 9V battery between the two sensors to block some of the light from spilling over and affecting the readings of the second photocell when Ard-e was turned one way.

Here is a video of Ard-e following the light from a flashlight that I was shining at him then veering off and going towards the light coming from the door. The quality of the video is really bad because the readings of the sensors get all screwy if alot of background light is present.



Now on to making Ard-e smell and hear.

Step 7: Ard-e's Sense of Hearing and Smell: Interfacing an Old Speaker and a VOC Sensor With an Arduino

So to give Ard-e the final two senses that he really needs, hearing and smell, all you need is an old speaker and a Volatile Organic Compound sensor.

So to make Ard-e hear the world and react very simply to it all you need is an old headphone. Just as a headphone can turn electrical pulses into sound it can turn sound into electrical pulses. All you need to do is hook one of the leads from the headphone to ground and one of them to an analog input on the Arduino. The program to very simply interface this with the Arduino is to make a threshold that is set very low maybe like 2 or 5 and if the analog input is driven higher than this threshold make Ard-e react. You can implement it like the clapper where clapping makes him turn on or off. I was able to use an old headphone in the very preliminary stages of making Ard-e to act as a clapper but by the time that I got Ard-e up and running by himself the headphone no longer functioned as a microphone so I didn't actually make Ard-e interface with it. The microphone/ headphone was proven to work as an input to the Arduino though.

To get finer resolution on Ard-e's ability to hear you might want to use an OPAMP based inverting amplifier with an adjustable gain. I attached a schematic of a circuit that I think would work ideally for this but I didn't test it out so be careful if you choose to attach it to your Arduino.

To get Ard-e to smell is a little pricey though. All it takes is a VOC sensor hooked up to an analog input of the Arduino. The sensors run around $22 a piece though. I'm now going to link you to an instructable that my brother wrote about how to use these sensors with the Arduino but be warned... he never wears a shirt and is sorta a tool. Follow the link with caution:
https://www.instructables.com/id/How-To-Smell-Pollutants/
Once this sensor is attached to the Arduino its a simple matter to write a program that makes it drive to where the concentration of VOC's is the highest and set off an alarm. To easily make an alarm for the Arduino all that I did was take apart an old broken alarm clock take the piezo-electric buzzer and attach it to one of the digital PWM output pins. A simple call of analogWrite(the pin, and a value from around 10-255) produces a very nice alarm noise.

So now Ard-e can see, smell, touch and hear the world around him. He can even produce tones too. These are all really important senses but robots need some other senses that humans don't necessarily need. Lets build Ard-e some sensors so he can have some robot senses.

Step 8: Ard-e's Robot Senses: Tracking How Far His Wheels Turn and Seeing IR Light

Since humans don't have wheels their is really no need for us to be able to track how far our wheels have turned. Ard-e being a wheel based robot however needs to know this. To accomplish this you can employ many different methods. An instructable was just submitted for this contest that takes the data from an accelerometer then extrapolates the distance from that. For Ard-e however all we are going to need is an LED and another light sensor. We just need to shine a led through his tracks and then have a light sensor on the other side count how many times the light changes from high to low. Once you have a count on this number you can measure the distance between holes in the tread and correlate this to a distance. Or you could just set Ard-e to drive for a number of counts of the light switching from high to low then measure the distance that he traveled to get the conversion factor from counts to inches (or centimeters if you like working in SI). Then you can literally program Ard-e to go exactly six feet forward turn right go forward a foot or any other course you want it to take.

To actually build the sensor I used my trusty piece of scrap metal and folded a rectangular piece of it into a U shape. I drilled a hole to mount it into the side of Ard-e and then two holes for the led and the light sensor to fit into. I mounted it onto Ard-e so that the led shines right through the center of the holes in the treads onto the light sensor. I put the light sensor on the top part of the U and then put some electrical tape around the sides of the U to block out some of the ambient light that would mess up the readings of the light sensor. I then connected the light sensors just like I connected them for making Ard-e sense where the brightest light is, as a voltage divider to an analog input (using the same input pins and resistors as the "eyes" of Ard-e). The led was soldered to a resistor sized to enable it to run off of 5V and then plugged into the power being supplied by the Arduino.

Just by moving the wheel manually and watching the values that the Arduino outputs using the Serial.print() command to the serial monitor you can get a 600 point swing on the scale of 0-1023. The low is around 200 and the high is around 800. I attempted to write a program that uses 400 as the cutoff for a low to high value and counted the times it switched from below to above 400 but it was beyond the scope of my programming abilities. I think it was because i was using too slow of a speed on the serial printing and checking of the values of both sensors and the treads were being spun pretty fast. When I tried to use a higher speed it wouldn't print at all. In retrospect I don't even need to have the values printed. I wasn't able to get the Arduino to correctly read the values coming from the sensors as the wheels were spinning but I demonstrated that it was possible to use this sensor to count the number of times that the tread interrupted the light from the LED to the light sensor. And if your a better programmer than I am you could convert this number to a distance and program Ard-e to drive to that distance.

Another of Ard-e's robot senses that would be awesome for him to have is being controlled by an old VCR remote. I found a remote in the old pile of electronics junk and found a infrared Radiation sensor at Radio Shack. All that you would need to do is hook the infrared sensor up to the +5V and Ground and then the output to an analog input on the Arduino, just as it says on the back of the box for the sensor. Again if your a much better programmer than I am you could then program the Arduino to recognize the IR signal from the remote and correlate it to making Ard-e move. If the up arrow on the remote is pressed make Ard-e drive forward, if the down arrow on the remote is pressed go backwards, etc. I bought the sensor from radio shack but haven't been able to get the Arduino to interface with it it yet.

So now Ard-e's senses are complete! Or at least as complete as I can make them. You on the other hand should get started recycling some old junk to add on as sensors for your own version of Ard-e. Now whats next for Ard-e?

Step 9: The Future of Ard-e: What Comes Next

So what should I do now that I have a really cool autonomous robot? Make him even cooler of course. I would absolutely love to have Ard-e controlled by a wii remote. That would be excellent. Its really far beyond my programming skills though. Interfacing him with a cheap cell phone to make him do different things when the phone is called or texted would also be pretty cool. I feel like Ard-e should also have some more manipulators so he can not only sense the world but also interact with it.
I found a crappy old joystick at a junk store that is just begging to be used to control Ard-e. It doesn't seem like it should be that much of a challenge to control him with it so I hope to do that soon.

This is the end of my instructable so the other ideas for making Ard-e cooler have to come from you. Get working and post what you come up with as an instructable!

Hopefully you liked this instructable and will vote for it in the RobotGames Contest. Leave any questions about the building of or attempts i made at programming Ard-e as comments and ill do my best to answer them.

Instructables and RoboGames Robot Contest

Second Prize in the
Instructables and RoboGames Robot Contest

The Instructables Book Contest

Participated in the
The Instructables Book Contest