We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to get the values read off from an arduino but I get a number format exception at the line where the line 'val = Integer.parseInt(s);' occurs. What's going on?
import processing.serial.*;
Serial myPort;
String portName;
String s;
int val;
void setup(){
size(displayWidth/2, displayHeight/2);
portName = Serial.list()[2];
myPort = new Serial(this, portName, 9600);
}
void draw(){
s = myPort.readStringUntil('\n');
if (s != null) {
val = Integer.parseInt(s);
println("giving val number");
}
print("From " + portName + ": \n"); //print it out in the console
//println("\"" + s + "\"");
println(val);
}
Answers
http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#parseInt-java.lang.String-
http://processing.org/reference/intconvert_.html