Serial myPort; // The serial port int xPos = 1; // horizontal position of the graph int chCount = 0; String[] ChVa; float[] ChVo; PFont font;
void setup () { // set the window size: size(600, 480);
// List all the available serial ports println(Serial.list()); // I know that the first port in the serial list on my mac // is always my Arduino, so I open Serial.list()[0]. // Open whatever port is the one you're using. myPort = new Serial(this, Serial.list()[0], 9600); // don't generate a serialEvent() unless you get a newline character: myPort.bufferUntil('\n'); // set inital background: background(0); font = loadFont("CenturySchoolbook-32.vlw"); textFont(font); } void draw () { // everything happens in the serialEvent() } void serialEvent (Serial myPort) {
// get the ASCII string: String inString = myPort.readStringUntil('\n');
if (inString != null) { // trim off any whitespace: inString = trim(inString);
//split string into array ChVa = split(inString, ',');
//convert string array to integer array and scale for (int i = 0; i < 6; i++) { int tmp = int(ChVa[i]); ChVo[i] = tmp*0.0049; }
Stable Library ========================================= Native lib Version = RXTX-2.1-7 Java lib Version = RXTX-2.1-7 [0] "COM6" error, disabling serialEvent() for //./COM6 java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at processing.serial.Serial.serialEvent(Unknown Source) at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732) at gnu.io.RXTXPort.eventLoop(Native Method) at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1575) Caused by: java.lang.NullPointerException at _6_Ch_Display.serialEvent(_6_Ch_Display.java:81) ... 8 more