## 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 = 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.
That looks so hard and complicated idk how you could build that for a science fair project I am just saying well i guse some people are smart about building robots but I could not build that and what is it post to do? nothing or dose it move around? can it talk? can it pick things up? WHAT can it do?
does it even lift?? ;-P <br>awesome robot and instructable, i&acute;m trying to build a roomba bot while learning robotics (my knowledge go as far as H-bridge..), also i was thinking about buying an arduino board, now i&acute;m ordering one stat! <br>congrats..
Hey could a adruino uno work?
I tried to use your servo code, but I can't even get the Arduino IDE to compile it.<br><br><br>#include <br><br>int potPin = 2; // selects the input pin for the potentiometer<br>Servo servo1;<br>int val = 0; // variable to store the value coming from the potentiometer<br><br>void setup() {<br> servo1.attach(8); //selects the pin for the servo<br>}<br><br>void loop() {<br> val = analogRead(potPin); // read the value from the potentiometer<br> val = val / 5.68; //convert the value to degrees<br> servo1.write(val); //make the servo go to that degree<br> Servo::refresh(); //command needed to run the servo<br>}<br><br>=====================================================<br>The IDE seems to have a problem with the following line in your code:<br><br> Servo::refresh(); //command needed to run the servo<br><br>do you have a solution for this error?<br> I'm running the latest version of Arduino IDEs version 0023.
The latest version of the Arduino IDE is 0100<br><br>and try using Servo.refresh();
&quot;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&quot;.<br>Would this be caused by the first motor (#1) in line with the + would cause a voltage drop to motor (# 2)?. Would placing a resistor in line with M#1 control the voltage better? <br>Another possible work around for this is to use the chip to control the ground circuit from the motor.<br><br><br>Just a thought, as most DC motors in automotive interiors use &quot;Hot&quot; motors and use the PCM directly or the PCM controls micro relays to control the ground to operate.<br><br>NooB.
Is that a toilet cleaning brush I see? (on the first picture) :) Nice 'ible!
In the code are those declarations in the begging pin numbers?<br>
Anybody know how this was interfaced as a voltage divide?
I love this instructable! 4/5* (becuase of the lack of code) Other than that Awesome! I really love how you made the robot with a lot of different functions..
where's the actual code for the light seeking behavior?
I forgot to post the code for it and it was written on my old laptop... I did it two different ways. The first way was with two light sensors mounted on the left and right sides and pointing forward. I then programmed it to spin the side that had a higher reading faster. The other way that I did it was to mount a single light sensor in the middle of A-rde on a servo and have the servo turn to the left right and middle and measure the light at these three points. Whichever was the brightest it would drive towards, stop and then make another measurement. I never really got good light seeking behavior...
Also, try making adjustable eyes. Use solid core wires soldered onto the two LDR pins and then twist the wires together. there bendy yet they hold their shape. i found that the best way to get them to work is pointing them upwards, bent slightly away from each other...
i tried the first method with the cds cells connected to analog pins 1 and 2. the analog pins had 10k ohm resitors going to ground and the other end of the cds cell went to +5v. I'll PM the code for what i used, I got excellent behavior, very accurate. BTW, i used a l298hn chip instead of the l239d, because i was able to sample it. You should change the code for the l239d, and I dont mind if you post it on the I'ble for others to use.
instead of the l293, i sampled the l298HN IC which is similar to the l293. but i got it for free...
&nbsp;why are there pins coming out of the bottom of the schematic sorry im pretty new to this.
the pins come out the bottom to make a simple design on the schematic. When actually building this, you should use the data sheet or any other reference to match the pin numbers on the schematic.
use the joy with an X-bee and make a Ard-e wireless and a camera so you can remotely control it from your computer and maybe a weapon system! <br />
Awesome instructable. Thanks for all the input. wanting to get a freeduino to start playing around with. Also thank your brother for the VOC, I know my cousin is going to freak when I finally get this worked out and the robot rolls up to his shoes and then waves it's little claw in front of it's sensor array/face does a 180 and speeds away.
I really like it, I was thinking of buying an arduino, but now that I have seen this project I'm deffinately going to buy one. I'm thinking of making a mobile platform out of knex (instead of the bulldozer) I have a question though, I assume the motors from the bulldozer use 3v each and you hook up a 6v power supply because the L293 needs it, so how do you run the motors?
Originally i had the L293 hooked up with only 3V supplied to it and then attached another batter pack because it wasn't working. The motors held up fine probably because i usually don't run them at a full duty cycle for very long.
love it here is a robot im making
I noticed that in your first video you are apparently controlling the robot by means of some switches that are physically wired from your controller to the robot. May I suggest using a wireless transmitter and receiver to make it remote controlled? I'm sure it will be worth the extra \$10 - \$15 and several new lines of code.
you should make a programmable paint ball gun like this then make an instructable awsome <a rel="nofollow" href="http://www.youtube.com/watch?v=-JvxnrzB1Jk&amp;feature=user">http://www.youtube.com/watch?v=-JvxnrzB1Jk&amp;feature=user</a><br/>
Instead of using L293 to drive the motors, you could have also used a TIP120 transistor instead of spending senven dollars, or 20 for a driver.
groovy little brother! glad to see all my stolen electronics components going to a good use:)
I have arduino and the tank kit. I should make this!
Make sure you post a link to it if you do!
ok, i just have to get a servo and some other stuff
Nice Job!! I was using the same bulldozer platform for the wall-e testing until I got a u-command wall-e now the electronics are in that so I can finnish the progrmming. Plus I like your instructible nice layout too. congrats. a++
Thanks. Wall-e is awesome, he was part of my inspiration for this project.
It's good to see that 4mem8 andI could inspire you and others that was our job to get the younger generation involved into thinking and modig what they see in robotics. Plus you have inspired people also, you got my vote!
<sub></sub><sub></sub><sub></sub><sub>that is nice</sub><sub></sub><sub></sub><sub>it would be better if you add more switches of not falling off the stairs hehe</sub><br/>
kool
Very nicely written. I've been contemplating an Arduino and needed a project to start with, I think this is just the inspiration I need. I especially liked the info about the sensors and such. Thanks!
Kool project :) I like most arduino projects :D but this one is nice and detailed :)