pixy : https://pixycam.com/
I've done a code for my arduino and it has an error :
The goal is to stop the servo when the pixy x variable is between or equal 150 and 160 and when it is, its not stopping the servo.
Say to me if i'm not clear enough
Code :
#include <Pixy2.h>
#include <Servo.h>
Pixy2 pixy;
Servo myServo;
Servo myServo2;
Servo myServo3;
void setup() {
// put your setup code here, to run once:
pixy.init();
myServo.attach(9);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
myServo.write(0);
for(int b = 0;b<180;b++)
{
int i;
pixy.ccc.getBlocks();
if (pixy.ccc.numBlocks)
{
int pX = (int32_t)pixy.ccc.blocks[0].m_x;
Serial.println(pixy.ccc.numBlocks);
if(pX<= 150 && pX >= 160)
{
break;
}
else {
delay(5);
myServo.write(b);
}
}
else
{
delay(5);
myServo.write(b);
}
}
delay(10000);
}
Thx