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
#include <SPI.h>
#include <Pixy.h>
Pixy pixy;
void setup()
{
analogWriteResolution(12);
pinMode(22, OUTPUT);
Serial.begin(9600);
Serial.print("Starting...\n");
pixy.init();
}
void loop()
{
static int i = 0;
int j;
uint16_t blocks;
char buf[16];
int Xpositie;
int Ypositie;
blocks = pixy.getBlocks();
if (blocks)
{
i++;
if (i%50==0)
{
sprintf(buf, "Detected %d:\n", blocks);
Serial.print(buf);
for (j=0; j<blocks; j++)
{
sprintf(buf, " block %d: ", j);
Serial.print(buf);
pixy.blocks[j].print();
//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
delay(50);
}
// 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
else
{
digitalWrite(22, LOW);
delay(50);
}
}
}
}
}
can someone tell me whats wrong and how to fix it.
Moderator edit: CODE TAGS.