Hello,
I want to do 2 things using arduino and processing.
I have a couple of lines which I want to output:
Serial.println("Line1");
Serial.print("\n");
Serial.println("Line2");
Serial.print("Score: ");
Serial.print(counter);
I want the first 3 lines to be seen as this in processing:
Line 1
Line 2
And I want the score to be positioned somewhere else.
My processing code:
import processing.serial.*;
Serial myPort;
PFont font;
PImage bg;
PImage banana;
int X, Y;
int nX, nY;
int delay = 5;
int linefeed = 10; // new line ASCII = 10
float radius = 50.0;
String myString = null;
void setup () {
printArray(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.clear();
myString = myPort.readStringUntil(linefeed);
myString = null;
font = createFont("Arial", 20, true);
size(960, 540);
fill(0);
textFont(font);
bg = loadImage("Snow.jpg");
banana = loadImage("banana.png");
strokeWeight( 10 );
frameRate( 60 );
X = 200;
Y = 200;
smooth(8);
}
void draw() {
while (myPort.available() > 0) {
myString = myPort.readStringUntil(linefeed);
if (myString != null) {
if (myString.equals("clearscreen\n") == true) {
if (bg.width != width || bg.height != height) {
bg.resize( width, height );
}
this.background(bg);
image(banana, 700, 50, 50, 50);
} else
text(myString, X, Y);
}
}
}
How can I do that?