Ard-e: The robot with an Arduino as a brain

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.
Remove these ads by Signing Up