Hii,
I have just bought Pixy and it’s working very well with PixyMon but when i hook it to my Arduino it is just silent
and always respond in the serial monitor with “reorder” and sometimes “cs error”.
this is my code:
#include <Servo.h>
#include <SPI.h>
#include <Pixy.h>
Servo myservo;
Pixy pixy;
int BaseMotorDir = 2, BaseMotorPWM = 3, GripMotorDir = 4, GripMotorPWM = 5,
Rover5LeftMotorDir = 12, Rover5LeftMotorPWM = 11, Rover5RightMotorDir = 8, Rover5RightMotorPWM = 6;
int BaseMotorCurrentDir = 0, GripMotorCurrentDir = 1, RoverLeftCurrentDir = 0, RoverRightCurrentDir = 0, pos = 0;
//A0 ===> Upper Base Limiter
//A1 ===> Lower Base Limiter
//A2 ===> Grip Limiter
//0 ====> BaseMotorDir = Downwards
//1 ====> BaseMotorDir = Upwards
//0 ====> GripMotorDir = OpensUp
//1 ====> GripMotorDir = ClosesDown
bool Valid = true;
void setup()
{
// put your setup code here, to run once:
myservo.attach(9); // attaches the servo on pin 9 to the servo object
pinMode(BaseMotorDir, OUTPUT);
pinMode(BaseMotorPWM, OUTPUT);
pinMode(GripMotorDir, OUTPUT);
pinMode(GripMotorPWM, OUTPUT);
pinMode(Rover5LeftMotorDir, OUTPUT);
pinMode(Rover5LeftMotorPWM, OUTPUT);
pinMode(Rover5RightMotorDir, OUTPUT);
pinMode(Rover5RightMotorPWM, OUTPUT);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
Serial.begin(9600);
pixy.init();
}
void loop()
{
// put your main code here, to run repeatedly:
if (Valid)
{
myservo.write(1);
Serial.print(“Initial Delay Start Up 5 seconds\n”);
Serial.print(“5\n”);
delay(1000);
Serial.print(“4\n”);
delay(1000);
Serial.print(“3\n”);
delay(1000);
Serial.print(“2\n”);
delay(1000);
Serial.print(“1\n”);
delay(1000);
Serial.print(“0\n”);
uint16_t blocks;
while (true)
{
blocks = pixy.getBlocks();
//pixy.getBlocks();
for (int i = 0; i < blocks; i++)
{
//if (pixy.blocks[i].signature == 1)
{
Serial.print(pixy.blocks[0].x);
Serial.print(" - ");
Serial.print(pixy.blocks[0].y);
Serial.print(" - ");
Serial.print(pixy.blocks[0].width);
Serial.print(" - ");
Serial.print(pixy.blocks[0].height);
Serial.print(" - ");
Serial.print(pixy.blocks[0].signature);
delay(3000);
Serial.print("\n");
}
}
Serial.print("Delay 3 secs\n");
delay (3000);
}
Valid = false;
}
}
but nothing works. Also i did try the hellow world example with the library but all in vain.
I am using the SPI port and am sure that the Dataout is set to “0”. also i have the signature saved on the pixy’s flash.
One more thing, its always flashing white color while hooked and working with arduino.