<< return to Pixycam.com

Change Pan Reset to Sweep

Hello, I am using the Pixy2 Pan/Tilt, when the camera doesn’t see the object it reverts to an origin position. I would like to change this so that when it doesn’t see an object, the tilt does revert back to its original position but the pan does a sweeping surveillance motion to look for this object. Does anyone know how this can be done??

Hello,
Here’s the ccc_pantilt code:

Notice on lines 72-73, it deals with the case where there is nothing detected. You can put your sweeping code here. You might try writing and debugging the sweeping code in a separate program and then copying it into the ccc_pantilt.ino file.

Hope this helps!

Edward

1 Like

Hi Edward, what is the port name for the pan port of the pixy2? as I need to include where the servo is connected. Or can I just make a sweeping code without including a port? Thanks!

Hi Edward, would I include this sweeping code into the panLoop.reset(). Such as panLoop.reset(sweep.h)

Hi David,

sorry for the delayed response! I think Edward was suggesting that you remove the panLoop.reset() and tiltLoop.reset() statements, and replace them with some function you write yourself that produces a sweeping motion.

For the sweeping function, the pixy.setServos(panValue, tiltValue) command is what sends the values to the servos. You can replace panValue and tiltValue with any integer from 0 to 1000.

Here’s the API docs, FYI: https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:arduino_api#int8_t-setservos-uint16_t-s0-uint16_t-s1

Hope this helps!

Cheers,
Jesse