Hi Omer,
It sounds like you want to determine the signature of an object and do something based on that signature correct? You need to include the appropriate header files , initialize the pixy and the use the function pixy.getBlocks() to populate the pixy.blocks array. You can then check the signature of each color block with @pixy.block[i].signature@. Where i is the block number, this will return a number based on what color signature the block is. For example, if you have blue assigned to signature 2, then it will be equal to 2 when seeing a blue object.
Here is some pseudo code that might do what you are asking, I am not in front of my development machine so I have no way to test but this should be pretty close:
#include
#include
int sigRed = 1; // signature 1 is red objects
int sigBlue = 2; //signature 2 is blue
Pixy pixy; // instantiate a Pixy object
void setup() {
pixy.init(); // initialize the pixy
}
void loop() {
uint16_t blocks;
while (1)
{
blocks = pixy.getBlocks();
if ( blocks)
{
for (i = 0; i< blocks;i++)
{
if (pixy.blocks[i].signature == sigRed)
{
Do stuff for red blocks
}
else if (pixy.blocks[i].signature == sigBlue)
{
Do stuff for blue blocks
}
}// end for
}// end if(blocks)
delay(50); // dont poll thge pixy too fast
}// end while
}