Go Down

Topic: Simple serial two servo (camera pan/tilt mount) control (Read 1 time) previous topic - next topic


I just finished up a simple and crude interface to allow me to control servos on a small pan/tilt camera mount I picked up off of ebay. My intention is to set up a PhpSerial script that will respond to ajax calls to control the camera mount from a webcam page I set up on my Raspberry pi. (I also have an expansion board on the pi that I will eventually hook up to get the arduino out of the loop but it uses mini connectors and I don't have adapters)


This is basic and I tried to pull the basic setting stuff out to the top. The main loop is the serial read and it calls the various functions to pan/tilt/center the two axis.

u = up
d = down
r = right
l = left
c = both axis to center
t = tilt (up/down) axis to center
p = pan (left/right) axis to center

After each command, the arduino will return the current tilt and pan axis values (although the tilt axis is inverted with a non-hanging mount which is what I'm using so in this example, the values are inverted for the tilt axis with 180 - s1pos).

You can also specify the limits near the top if you want to reduce either the pan or tilt maximum angles. (note, these are NOT reversed for tilt. min will represent the 'top' angle in a non-hanging camera) In my case, I'm hoping to point this first at a fish tank, then later out a back window and eventually use it on a remote system out in the forest. The servos I have are 180 degree rotation and I don't really want folks looking around my house.

I hope some folks find it useful. If I get the thing working with the ajax/php stuff, I may post a link.

Go Up