Hello! New here and haven’t been able to really find anything super helpful for what I specifically need. I’m a super beginner…n00b, really. My professor is helping me with this but we haven’t quite figured it out yet and I thought I’d try here while I wait to meet with him again.
I have a Pixy2 Camera plugged up to an Arduino Uno, and I’m communicating data through the serial port to Processing. The Pixy cam is picking up color “signatures” I have set and drawing rectangles around each one, and giving me information for each color detected (how many colors are detected (as blocks), which block, its signature, x, y, width, height, index and age)
My goal is to create an interactive / generative piece that involves a hula hoop I have wrapped in different colors of tape. Basically, I would like to use the x, y, width and height data to generate imagery. For now, I’d really just like to start simple and make an ellipse appear for every time a color, or block, is recognized.
Please see below for reference to what is coming in through the serial port to the console:
I need to know how to pull the numbers and use them. We tried splitToken with “:” but it didn’t work out very well, because it was also pulling the text out.
Here’s an example of what the Pixy cam is doing.
PROCESSING CODE:
import processing.serial.*;
Serial myPort; // The serial port
Boolean firstContact = false;
void setup(){
myPort = new Serial(this, Serial.list()[2], 115200);
}
void draw(){
}
void serialEvent( Serial myPort) {
//println("serial event");
//put the incoming data into a String -
//the '\n' is our end delimiter indicating the end of a complete packet
String val = myPort.readStringUntil('\n');
//make sure our data isn't empty before continuing
if (val != null) {
//trim whitespace and formatting characters (like carriage return)
val = trim(val);
println(val);
//look for our 'A' string to start the handshake
//if it's there, clear the buffer, and send a request for data
if (firstContact == false) {
if (val.equals("A")) {
myPort.clear();
firstContact = true;
myPort.write("A");
println("contact");
}
} else { //if we've already established contact, keep getting and parsing data
println(val);
if (mousePressed == true)
{ //if we clicked in the window
myPort.write('1'); //send a 1
println("1");
}
// when you've parsed the data you have, ask for more:
myPort.write("A");
}
}
}