FTC Team 6596 Pixy Cam Guide for use with the REV Expansion Hub

Using a download from CMUcam.org called Pixymon you can "train" your cam.

http://cmucam.org/projects/cmucam5/wiki/Install_PixyMon_on_Windows_Vista_7_8

We are using the I2C protocol, use this link to help with that. (Be sure to change in Pixymon the interface data out port to LEGO I2C)

cmucam.org/attachments/1290/Pixy_LEGO_Protocol_1.0.pdf

What we found is the 5V in & the ground we ran to the 5V port on the REV Hub and stopped using the level shifter.

Pin 2 to one of the two separate 5V power outputs on the REV Hub (we used servo extension wire, cut it and splice with solder and heat shrink)
Pin10 to either ground post on the same port as used above (we used servo extension wire, cut it and splice with solder and heat shrink)
Pin 5 to the blue wire on a REV I2C wire ((cut it and splice with solder and heat shrink)
Pin 9 to the white wire on a REV I2C wire (cut it and splice with solder and heat shrink)

Pin count goes Left to Right, Top

to Bottom kind of like below.

1  2

3  4
5  6
7  8
9  10



As far as coding here is what you would need:

//Declare a new I2cDeviceSync
I2cDeviceSync pixyCam;
//Get name from hardware config
pixyCam = harwareMap.i2cDeviceSynch.get("pixyCam");

//Now to get data
//Signature Query
//This query simply asks Pixy to return the largest detected block of the specified signature. The
//specified signature is the Query Address ­ 0x50. For example, a Query Address of 0x51 would
//request the largest detected block of signature 1.
//Query Address Optional Query Data Pixy Response
//0x51 thru 0x57 none 5 bytes that describe the largest detected block within all signatures 1 thru 7. If no object is detected, all bytes will be 0.
//Byte Description
//0 Number of blocks that match the specified signature.
//1 X value of center of largest detected block, ranging between 0 and 255. An x value of 255 is the far right­side of Pixy’s image.
//2 Y value of center of largest detected block, ranging between 0 and 199. A value of 199 is the far bottom­side of Pixy’s image.
//3 Width of largest block, ranging between 1 and 255. A width of 255 is the full width of Pixy’s image.
//4 Height of largest block, ranging between 1 and 200. A height of 200 is the full height of Pixy’s image.
//All of this info and more can be found at cmucam.org/attachments/1290/Pixy_LEGO_Protocol_1.0.pdf

pixyCam.engage();
sign1 = pixyCam.read(0x51,5);
sign2 = pixyCam.read(0x52,5);
//notice the 0xff&sign1[x], the 0xff& does an absolute value on the byte
//the sign1[x] gets byte 1 from the query, see above comments for more info
telemetry.addData("X value of sign1", 0xff&sign1[1]);
telemetry.addData("X value of sign2", 0xff&sign2[1]);