<< return to Pixycam.com

Signatures in Arduino

Hey,
I am trying to print on Arduino different signatures. Do you guys know how to do this?
so like:
void setup()
{
Sign’Red = 0;
Sign’Blue = 0;
}
i already created the signatures on the PixyMon and they work fine. also the arduino works with one signature, but I still want the arduino to be able to tell the different between two signatures

Thank you !

O

Hello Omer,
I’m having trouble understanding your question. The signatures are stored in Pixy’s flash memory.

When you run the hello_world example in Arduino, the signature number of the detected object(s) is printed with the x, y, width, and height information. This is how your Arduino program tells the difference between signatures, by looking at the signature number.

Hope this helps.

Edward

I am trying to program something that would alert depend on the object position.
How do I write a signature as a variable?

thank you !

Omer.

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
}

David,
we have tried to run it, but the arduino still cannot tell the difference between the two colors. I set up both signatures and it still looks at it as an object instead of the color. i tried to put in the intro " int sigRed = 1; " and “int sigBlue = 2;” and still did not work.

Please help!

Omer and Zach.