<< return to Pixycam.com

help ...

Hi …

I registered in camera Pixy 3 colors … I want to use 2 or 1 colors each time … ( dénombrements)

So that I get a certain action each time Whenever 3 colors different are detected …

Save 3 colors in Camera Pixy è Pull 2 or 1 colors different è Action

     pixy.blocks[j].print();
    signature = (pixy.blocks[j].signature); 

1 if (signature == 1)
{
digitalWrite(8,HIGH);
delay(1000);
}

2 else if (signature == 2 )
{
digitalWrite(7,HIGH);
delay(1000);
}

3 else if (signature == 3)
{
digitalWrite(6,HIGH);
delay(1000);
}
4 else if ((signature == 3)and (signature == 1))
{
digitalWrite(8,HIGH);digitalWrite(7,HIGH);
delay(1000);
}
5 else if ((signature == 3)and(signature == 2))
{
digitalWrite(6,HIGH);digitalWrite(7,HIGH);
delay(1000);
}
6 else if ((signature == 2)and(signature == 1))
{
digitalWrite(8,HIGH);digitalWrite(6,HIGH);
delay(1000);
}

Problem :::but in the 3rd, 4th and 5th condition if … the diode is not lit at the same time ???

Hello,
It sounds like you’re asking about the RGB LED. It lights up when Pixy detects 1 or more objects and the color is the color of the largest detected object in the image.

Regarding your code, it looks like it won’t compile, but it sounds like you are asking how to determine if all 3 objects are detected at the same time? Here is my attempt to write such a detector using Pixy:

  int j;
  uint16_t blocks;
  bool sig1, sig2, sig3;

  // grab blocks!
  blocks = pixy.getBlocks();
  
  if (blocks)
  {
      sig1 = false;
      sig2 = false;
      sig3 = false;
      for (j=0; j<blocks; j++)
      {
        if (pixy.blocks[j].signature==1)
          sig1 = true;
        else if (pixy.blocks[j].signature==2)
          sig2 = true;
        else if (pixy.blocks[j],signature==3)
          sig3 = true;
       }
    if (sig1 && sig2 && sig3)
       Serial.println("Sigs 1, 2, 3 are present");
  }  
}

Hope this helps!