Hello,
I have successfully made Pixy2/Zumo robot that runs well
with ccc_zumo_chase software. Now want to add a pan scanning
function to the block searching section, but I can control
the pan/tilt servos. Below is a simple attempt to contol the servos.
It deos not work. What is wrong? Thanks.
#include <Pixy2.h>
#include <PIDLoop.h>
#include <ZumoMotors.h>
Pixy2 pixy;//create pixy object
ZumoMotors motors;
PIDLoop panLoop(350, 0, 600, true);
PIDLoop tiltLoop(500, 0, 700, true);
int32_t panOffset;
int32_t tiltOffset = 600;
void setup() {
motors.setLeftSpeed(0);
motors.setRightSpeed(0);
pixy.init();
pixy.changeProg(“color connected components”);
}
void loop() {
pixy.ccc.getBlocks();
panOffset = 200;
panLoop.update(panOffset);
tiltLoop.update(tiltOffset);
pixy.setServos(panLoop.m_command, tiltLoop.m_command);
delay(2000);
pixy.ccc.getBlocks();
panOffset = 500;
panLoop.update(panOffset);
tiltLoop.update(tiltOffset);
pixy.setServos(panLoop.m_command, tiltLoop.m_command);
delay(2000);
pixy.ccc.getBlocks();
panOffset = 800;
panLoop.update(panOffset);
tiltLoop.update(tiltOffset);
pixy.setServos(panLoop.m_command, tiltLoop.m_command);
delay(2000);
pixy.ccc.getBlocks();
panOffset = 500;
panLoop.update(panOffset);
tiltLoop.update(tiltOffset);
pixy.setServos(panLoop.m_command, tiltLoop.m_command);
delay(2000);
}