<< return to Pixycam.com

variable to set condition - arduino uno

hi i have connected the pixymon to the arduino uno and i am able to set signature colour of green.

i understand that print(); is responsible for displaying the value.

i am trying to set conditions that if height or x or y goes out of place it will do something.

i am having trouble finding which is the variable to set in the void loop.

sorry if i sound unclear as it is my first time using arduino and this camera.

if i sound unclear please tell me as i will rephrase my sentences

appreciate it

Hi Kenneth,

Yes, the @print()@ function outputs the block data received from Pixy.

Try looking at “this”:https://github.com/charmedlabs/pixy/blob/master/arduino/libraries/Pixy/examples/pantilt/pantilt.ino example for how to access the x, y, height, etc from the block data.

If you want to do something based on a condition (like the x position of an object) then all you need to do is something like:

...

blocks = pixy.getBlocks();
if (blocks)
{
    for (j=0; j<blocks; j++)
    {
        if (pixy.blocks[j].x < 100)
        {
            Serial.print("X is less than 100!");
        }
    }
}

Is this what you were looking for? Good luck!

Scott