We are planning on using the pixy camera for vision this year (java), and we’ve been able to get the analog output running. However, we’d like to get more data off of the device. Does anyone have some kind of guide on how to get the two hooked up? I think I can do the wiring, but I don’t know where to start for code and the CD posts I looked at didn’t have working solutions or were in the wrong language.
We are in the process of doing the same thing but we are choosing I2C instead of serial (i.e. UART). Here is the documentation we used to hook it up and to program it.
http://cmucam.org/projects/cmucam5/wiki/Porting_Guide
Here is our code for reading pixy values sent from the arduino. It reads one character at a time and checks for the last character to be a ‘^’ before it creates the string, then it delimits that stiring to get all our values. Our arduino code is just using the pixy library to print the two blocks it sees. Hope this helps
public void getIt() {
str = serial.readString(1);
// System.out.println("Trying to Read");
if (str != null && !str.equals("^")) {
Finals += str;
// System.out.println("Collecting");
} else if (Finals.split(":").length == 8) {
// System.out.println(finalS);
String] tt = Finals.split(":");
try {
tt[0] = tt[0].substring(2);
if (Integer.parseInt(tt[0]) > Integer.parseInt(tt[4])) {
BiL = new BoxInfo(tt[4], tt[5], tt[6], tt[5]);
BiR = new BoxInfo(tt[0], tt[1], tt[2], tt[3]);
} else if (Integer.parseInt(tt[0]) < Integer.parseInt(tt[4])) {
BiR = new BoxInfo(tt[4], tt[5], tt[6], tt[5]);
BiL = new BoxInfo(tt[0], tt[1], tt[2], tt[3]);
}
// System.out.println("Left Box X:" + bIL.getX());
// System.out.println("Right Box X:" + bIR.getX());
springPos = (BiL.getX() + BiR.getX()) / 2;
// System.out.println("Width:" + tt[2]);
Finals = "";
} catch (Exception e) {
System.out.println(tt[0]);
System.out.println(tt[4]);
System.out.println(e);
}
} else {
Finals = "";
}
}