Hi everyone, I've done a simple code that is supposed to stop the ServoMotor while he is turning to 180 degrees when the pixy sensor detect an object. It doesn't work. I mean, when I present an object and the object is detected by pixy(verified), its doing nothing, nothing stops.
#include <Pixy2.h>
#include <Servo.h>
Pixy2 pixy;
Servo myServo;
void setup()
{
Serial.begin(9600);
myServo.attach(9);
pixy.init();
}
int b = 0;
void loop()
{
int b = 0;
while(b > 180)
{
myServo.write(b);
int i;
pixy.ccc.getBlocks();
delay(5);
if (pixy.ccc.numBlocks)
{
myServo.detach();
Serial.print("Detected")
break;
}
b++;
}
}