<< return to Pixycam.com

PIXY 2 Help to make a project

I have a PIxy 2 and Arduino Uno.
I am trying to make a simple project , I have 2 color circle type labels (Green and blue).
I need the Arduino to Turn On the pin 1 when the Pixy 2 detects the blue color label, and when the green color label is found TUrn On the pin 2.
I have teached the Pixy 2 the signature of the green label is the #1 and the blue label is the #2.
I have already run the example programs with the Arduino and they work.
Could you help me to find the way to get the signature number out fo the BLOCKS array and assign it to a variable? ( I don’t need X,Y data or the other infromation contained in the array).
I think with that I can make the comparison required and have the Arduino do the job.
But if you have a better solution, please share :slight_smile:
I am sorry to ask this simple stuff, buy I am stuck here.
Thank you

Hello,
Have you tried to run the “ccc_hello_world” example?

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:hooking_up_pixy_to_a_microcontroller_-28like_an_arduino-29

Edward

Thank you Edward.
I think I found the information that I need.
Is the array member: “pixy.ccc.blocks[i].m_signature” (to get the signature value only)
So my next question is how do I assign this value to a variable?
Perharps is: “a=pixy.ccc.blocks[i].m_signature” (Where “a” is a constant variable)

That’s correct. You’ll need to declare the variable before use – e.g.:

int a;

Hope this helps!

Edward

Thank you Edward, It did work!

Another question: How do I toggle On/Off the LED on the Pixy cam with the arduino?

Hi Gus,

you can use the setLamp(upper, lower) command - the arguments are binary values that correspond to:

Upper - turn on the two white LEDs along Pixy2 top edge
Lower - turn on all channels of lower RGB LED

So if you wanted to turn on the white LEDs, you’d call setLamp(1,0);
If you wanted to turn on the RGB LEDs, you’d call setLamp(0,1);
Or if you wanted to turn on both, call setLamp(1,1);

The function is documented here, but not in the Arduino API - I will make a note to fix this. https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:protocol_reference#setlamp-upper-lower

Hope this helps!
Jesse

Awesome, I am really happy with the Pixy Cam 2, is a good deal of price and performance, Functions and the ease of use; including the excellent support on the Forums :smile: