Go Down

Topic: Having trouble with arduino due/pixy program. (Read 116 times) previous topic - next topic

Feb 26, 2015, 10:05 am Last Edit: Feb 26, 2015, 10:10 am by AWOL
I downloaded this program from the pixy forums for the arduino due, but when ever I verify it i get this error message

pixyobject.ino: In function 'void loop()':
pixyobject.ino:48:21: error: invalid types 'uint16_t {aka short unsigned int}[int]' for array subscript
Error compiling.

Heres the program
Code: [Select]

#include <SPI.h> 
#include <Pixy.h>

Pixy pixy;

void setup()
  pinMode(22, OUTPUT);

void loop()
  static int i = 0;
  int j;
  uint16_t blocks;
  char buf[16];
  int Xpositie;
  int Ypositie;
  blocks = pixy.getBlocks();
  if (blocks)
    if (i%50==0)
      sprintf(buf, "Detected %d:\n", blocks);
      for (j=0; j<blocks; j++)
        sprintf(buf, "  block %d: ", j);
        //From here I assume Pixy is trained to see only objects of one specific colour and that there is not more than one object in the image.
        // If this object is detected pin 22 is high and the position is outputted as 2 analogue voltages on DAC0 and DAC1 of an Arduino Due
        if (blocks[j].signature==0)
              digitalWrite(22, HIGH);
              Xpositie=int(float(pixy.blocks[j].x/319*4095)); //Here the X-position of 0 to 319 is transformed to 0 to 4095 for the analogue output DAC0 of the arduino due.
              Ypositie=int(float(pixy.blocks[j].y/199*4095)); //Here the Y-position of 0 to 199 is transformed to 0 to 4095 for the analogue output DAC1 of the arduino due.
              analogWrite(DAC0,Xpositie);//The transformed X-position is here outputted to DAC0
              analogWrite(DAC1,Ypositie);//The transformed Y-position is here outputted to DAC1
        // If there is no object detected pin 22 is low and the values of the 2 analogue voltages on DAC0 and DAC1 is not important
              digitalWrite(22, LOW);

can someone tell me whats wrong and how to fix it.

Moderator edit: CODE TAGS.


Feb 26, 2015, 10:37 am Last Edit: Feb 26, 2015, 10:38 am by AWOL
Code: [Select]
  uint16_t blocks;
Code: [Select]
if (blocks[j].signature==0)

Clear now?

Code: [Select]
        if (pixy.blocks[j].signature==0)
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

it was signature ==0 before i changed it to 1 and in addition it the pins where connected to a GND

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131