Thanks for the reply Edward,
I just wanted to make sure of what you mean so I adjusted the code and here is a sample of it (for pixy), I would appreciate if you would take a look it.
Thank you for your time.
#include <AFMotor.h>
#include <SPI.h>
#include <Pixy2.h>
Pixy2 pixy;
int signature = 0;
int x = 0;                      //positon x axis
int y = 0;                      //position y axis
int Xmin = 0;                   //min x position
int Xmax = 315;                 //max x position
int Ymin = 0;                   //min y position
int Ymax = 207;                 //max y position
static int i = 0;
void setup() {
Serial.begin(115200);
pixy.init();
}
void loop() {
while(millis()<5000)
{
scan();
}
scan(); 
if(signature ==1 )//looking for signature 1
{
if (Xmin < x && x < 105 && y < Ymax && 138 < y) //go downleft if (0 < x < 105 , 138 < y < 207)
{
downleft();
}
}
void scan()
{
uint16_t blocks;
blocks = pixy.ccc.getBlocks();  //receive data from pixy
signature = pixy.ccc.blocks[i].m_signature;    //get object’s signature
x = pixy.ccc.blocks[i].m_x;                    //get x position
y = pixy.ccc.blocks[i].m_y;                    //get y position
}