I am working on a project right now which would require that a door be unlocked only when certain color coded objects were detected by the Arduino and am still learning the Pixy Arduino library. I am having trouble figuring out how to program the Arduino so that I can tell it if it sees this code go into this loop. What function would you use for the if statement?
Hello Justine,
You might start with the Hello_world example and see that it detects and prints the detected color codes. The rest is then doing something like
if (pixy.blocks[i].signature==)
There is more information on the API here:
http://cmucam.org/projects/cmucam5/wiki/Arduino_API
Hope this helps!
Edward
Amazing!however,so far,i still don’t know how to use "pixy.blocks[i].signature ".I’m puzzled over whether it just equal to or means a nunmber or not.if I code "x=pixy.blocks[i].signature ",it’s will be ok? And the “x” means The signature number of the detected object (1-7 for normal signatures).
Hello,
That’s the right idea. The signature field contains the signature number which is a number 1 through 7. You might try playing with the Arduino hello_world example. It prints out these fields and is a good starting point.
Edward