<< return to Pixycam.com

Pixy isn't working with my Arduino UNO

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.

Hey,

Try to run the Hello World program and see if you get anything.

Zach

I did but all i get is starting… and some times it’s followed by reorder.
i think that my Arduino SPI and Pixy’s SPI aren’t on the same page. some thing i wrong there.
i checked the library but it has all the initializations for Arduino’s SPI and for Pixy’s too !!
i also made sure that the defualt program is running and i did connect the arduino with USB and PIXY with USB and both connected with SPI.
nothing happened same silence !. the blocks are always giving ZERO they are always empty but in pixymon i have detected objects.
Can you help me please.

do you set a signature in PixyMon?

yes i did

Hello Esmail,
Let’s try to take some steps back. Please verify that you are using the latest firmware (2.0.8). You can check this by bringing up the “About” dialog in PixyMon.

http://cmucam.org/projects/cmucam5/wiki/Latest_release

Also, Please re-download the Arduino library and re-install. Try the “hello_world” Arduino example (unmodified) and let me know what you find.

If you are getting “reorder” messages, your Arduino and Pixy are talking. Perhaps there was an inadvertent modification or similar to the library or example code.

Edward

I did update now the library it turned out that i was using an old version of the library.
and i did try the Hello World now again but in vain -_-

Hello Esmail,
You should also make sure that you are in “default” mode. If you are in cooked mode (like in your picture), Pixy will not send data.

Edward