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!