Hey, quick update. My processing code right now:
// Example by Tom Igoe
import processing.serial.*;
Serial myPort; // The serial port
PImage img;
String val;
int lf = 10;
int cr = 13;
void setup() {
size(1280, 1280);
img = loadImage("FriendlyFire_0.png");
// List all the available serial ports
// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil(lf);
}
void draw() {
image(img, 0, 0);
//loadImage("FriendlyFire_" + val + ".png");
}
void serialEvent(Serial p) {
// Expand array size to the number of bytes you expect
byte[] inBuffer = new byte[7];
while (myPort.available() > 0) {
myPort.readBytes(inBuffer);
if (inBuffer != null) {
String myString = new String(inBuffer);
println(myString);
val = myString;
}
}
}
My input in the serial monitor:
47
1
2
3
What it looks like when I try to load images:
The file "FriendlyFire_null.png" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
The file "FriendlyFire_null.png" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
22
The file "FriendlyFire_22
** .png" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.**
Etc.
I apologize for my over newness. How do I assign the output of myString to val?