I’m using a Pixy on a different 2-axis gimbal than the demo kit, and I’m running my code on an Arduino Nano v3.1 board. I’ve modified the pantilt demo to work with my hardware, but would now like to add some code to “center” the gimbal on a set of known RCS position values (200, 570). I’d like to do this in two places in the code, at startup (e.g. center on power-up, then begin tracking after a short delay), and a poor man’s interrupt, using an SPST switch to toggle an input pin on the Arduino. The “in loop” interrupt would let me center the camera so I could train Pixy on a new color for Signature #1 and not have to fight with the servos swinging around at random. The switch would be flipped back to the “track” position, and the loop would start following the newly programmed color.
(Project overview: The gimbal also has a USB webcam attached to it. I intend to train Pixy on my child’s shirt/pants color and let the Pixy/webcam gimbal rig follow them around the living room, while Grandma & Grandpa watch/interact over Skype. The center-on-demand switch would let me hold the little one up and teach Pixy the current color to track)
I tried to brute-force the centering function, but was only able to make it work inside the loop() function; I simply commented out “pixy.setServos(panLoop.m_pos, tiltLoop.m_pos)” and added “pixy.setServos(200, 570)” in its place. That proved the concept, I just need to code up an if statement to check the state of the digital input pin wired to the switch. However, I tried the same thing inside the setup() function to perform a center-on-startup, but the servos didn’t seem to respond, even after adding a long (10 sec) delay after the setServos(200,570) call.
Any suggestions?
Thanks!