<< return to Pixycam.com

Pan - tilt

Hi everyone,

I am trying to control the position of the pan/tilt mechanism with two potentiometers attached to Arduino. I could also attach the servos to Arduino but doing it directly with the camera simplifies my project. I only have attached two potentiometers to two analog inputs and I communicate the devices via SPI. Here is the code (reeeeeeally simple):

///////////////////////////////////////////////////////

#include <SPI.h>
#include <Pixy.h>

Pixy pixy;

int potpin1 = 0, potpin2 = 1;
int val1, val2;

void setup()
{
pixy.init();
}

void loop()
{
val1 = analogRead(potpin1);
val2 = analogRead(potpin2);
pixy.setServos(val1, val2);
}

///////////////////////////////////////////////

It seems that the camera recognizes the signal because it reacts to the potentiometers changes, but I do not know what happens that the servos are acting sort of crazy, moving from one side to another without changes in the potentiometers, so I guess it is related to some problems with the current. I am powering Pixy with the SPI cable that comes from Arduino (which is fed via USB) Any idea about it? (Btw, I dont know if it is related, but the camera LED is a really strong blue)

Thanks in advance!

Hello Robert,
It definitely sounds like a power issue. Check out #1 below:

http://cmucam.org/projects/cmucam5/wiki/My_pantilt_is_acting_sort_of_crazy

You might consider powering your Arduino through the Pixy as suggested in the link.

Edward

I Have a couple off servo I want to use. I was looking for technical specs about the Pixy cam for the pin configuration for the servo. You show information on the 10 pin connection but nothing on the servo pins. The servo I have I used on my Arduino boards with no problem. The color coded wire on my servo are different from the servo you show. Could you please let me know which pin on the Pixy cam is for the ground, voltage and signal. I am thinking that the top pin for the servo close to the 10 pin connection is the signal and the second one is for voltage and the last one for ground. But I woul dlike to know for sure before I hook it up to the Pixy cam.
Thanks

Hello John,
This page should have the information you need:

http://cmucam.org/projects/cmucam5/wiki/Port_Pinouts

Edward