Hello,
I am in last year in high school, and I have for project of end of the year the programming of a robot. Among my various problematics, I must to make sure that the robot goes from one point to another one. To be done I decided to use a Camera Pixy .
I imagined that will be organized as foolows, There will be different panels (kind of checkpoints) that the robot will detect and with which it can move.But where I block it is at the Arduino program level :’(.
The only programs I’ve found allow the Pixy camera to detect only one object and track it, but I’ll want the camera to detect an object (for X time, or distance), then another (planel or an object ).
Can you help me please.
thank you in advance.
Hi,
have you tried using the hello_world Arduino program? It’s included with our Pixy Arduino library, code and instructions here: http://cmucam.org/projects/cmucam5/wiki/Hooking_up_Pixy_to_a_Microcontroller_(like_an_Arduino)
It should print to the console any objects that it sees. Pixy can track up to 7 different colors, with multiple objects in each color. Or, you can use color codes to create unique objects. This might be useful, since you can print out different stickers with color codes that you can use as checkpoints. Check out this page for more info on color codes: http://cmucam.org/projects/cmucam5/wiki/Using_Color_Codes
Hope this helps!
Best,
Jesse
Thanks a lot, I really appreciate.
I can’t see how I can change the object to follow in the Arduino program?
For example,I want Pixy track the first color (Yellow) for 10 seconds then goes to the second color (Red).
It’s all in the array that getBlocks() returns. More info: https://www.arduino.cc/reference/en/language/variables/data-types/array/
Basically, you just need some conditional logic to select the matching signatures.
For instance, modifying the Pixy hello_world example, you could add this just after “if(blocks){ i++”:
for (j=0; j<blocks; j++) { if(pixy.blocks[j].signature==1) { // do some action if any blocks from first signature are detected } else if(pixy.blocks[j].signature==2) { // do something else if any blocks from second signature are detected } }
Or you can set it up with a timer of some sort. Check out the SimpleTimer library for Arduino: https://playground.arduino.cc/Code/SimpleTimer
Hope this helps!
Best,
Jesse
thank you very much ^^
it helps me a lot
hello, excuse me to bother you again but I have a little trouble when compiling the program. it shows me;
"G: \ project SIN \ arduino \ battery \ drums.ino \ drums.ino.ino: 27: 18: fatal error: Pixy.h: No such file or directory
#include <Pixy.h>
^
compilation terminated.
exit status 1
Compilation error for the Arduino / Genuino Uno board "
Is it a problem due to the Arduino or the program?
here is my program:
"#include <SPI.h>
#include <Pixy.h>
// This is the main Pixy object
Pixy pixy;
void setup ()
{
Serial.begin (9600);
Serial.print ( “Starting … \ n”);
pixy.init ();
}
void loop ()
{
static int i = 0;
int j;
uint16_t blocks;
tank buf [32];
// grab blocks!
blocks = pixy.getBlocks ();
// If there are detect blocks, print them!
if (blocks)
{
i ++;
// do this (print) every 50 frames because printing every
// frame would bog down the Arduino
if (i% 50 == 0)
{
sprintf (buf, "Detected% d: \ n", blocks);
Serial.print (buf);
for (j = 0; j <blocks; j ++)
if (pixy.blocks [j] .signature == 1)
{
sprintf (buf, "block% d:", j);
Serial.print (buf);
pixy.blocks [j] .print ();
}
delay (1000);
else if (pixy.blocks [j] .signature == 2)
{
sprintf (buf, "block% d:", j);
Serial.print (buf);
pixy.blocks [j] .print ();
}
}
}
}
"
Thank you in advance
Hello,
Perhaps the Pixy Arduino library isn’t installed on that system?
This page describes how to install: