Saturday, September 29, 2012

Pan and Tilt

I added the optional Pan and Tilt Kit to give my range finder and webcam a place to live where the could be pointed on an arc covering the front of the 'bot.   The kit is designed as an accessory for the Explorer PCB and mounts nicely on it.   The pan and tilt mechanism is not a particularly highly engineered piece of gear but it works.   I had a little trouble assembling it as the tilt mechanism is somewhat fiddly. 

Wiring the servos is really pretty simple as the Explorer PCB has sockets for four servos on each side of the board.   Power to the appropriate pins on each of the sockets and the control pin back to the Arduino and we were done with the wiring.

The code is pretty simple but does need the servo library to make things happen.   

    #include <Servo.h>     // create servo object to control a servo     
    Servo myservo;         
    void setup()
    { 
        // attach servo on pin 24
        myservo.attach(24); 
    }
    void loop()
    { 
        // Move the servo to 10
        myservo.write(10);
        delay(1000);      
        // Move the servo to 120
        myservo.write(120);
        delay(10000);
    }

One of the challenges that I had was in getting the servos centered.   Make sure you have power them up and centered them BEFORE you mount them!   I also have a fair amount of servo chatter at various points on their arcs...a sign that I did not do a very good job of assembling the pan and tilt kit!

No comments:

Post a Comment