Hi all,
I am tracking the x and y coordinates of a colored object using the following Arduino code:
//
// begin license header
//
// This file is part of Pixy CMUcam5 or “Pixy” for short
//
// All Pixy source code is provided under the terms of the
// GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html).
// Those wishing to use Pixy source code, software and/or
// technologies under different licensing terms should contact us at
// [email protected]. Such licensing terms are available for
// all portions of the Pixy codebase presented here.
//
// end license header
///*
06.04.2014 v0.1.3 John Leimon
- Now using pixy.init() to initialize Pixy in setup().
*/#include <SPI.h>
#include <Pixy.h>Pixy pixy;
void setup()
{Serial.begin(9600);
// Serial.print(“Starting…\n”);pixy.init();
}void loop()
{
static int i = 0;
int j;
uint16_t blocks;
char buf[32];
int xvalue;
int yvalue;
//float widthvalue;blocks = pixy.getBlocks();
xvalue = pixy.blocks[0].x;
yvalue = pixy.blocks[0].y;Serial.println (xvalue);
Serial.println (yvalue);
//if (blocks)
// {
// i++;// if (i%50==0)
// {
// sprintf(buf, “Detected %d:\n”, blocks);
// Serial.print(buf);
// for (j=0; j<blocks; j++)
// {
// sprintf(buf, " block %d: ", j);
// Serial.print(buf);
// pixy.blocks[j].print();
// }
// }
//}
}
For whatever reason, it appears that the Pixy is collecting data at 100Hz instead of the 50Hz that the Pixy is reported to collect.
For example, when I record 500 rows of x and y coordinates (each x and y coordinate is one row), it takes only 5 seconds (100Hz) instead of 10 seconds (50Hz). Does anyone have any clue why this might be?
Thank you!
Ethan