[SOLVED] Error, disabling serialEvent() for COM3

Hey, I'm using Arduino to gather a string of data which looks like this in the serial monitor of Arduino:




I'm wanting to take this into Processing and split the strings so i can access a certain column from the data. The code I have at the moment is running the error in the discussion title every time I try to run it though. I've tried to solve the problem but with no luck, so I think there must be an error in my code somewhere in the serial event maybe?

I will post the code below, thanks for taking a look!

import processing.serial.*;

Serial myPort;        // The serial port
int xPos = 1;         // horizontal position of the graph

void setup () {
  // set the window size:
  size(400, 300);     

  // List all the available serial ports

  myPort = new Serial(this, Serial.list()[0], 9600);
  // don't generate a serialEvent() unless you get a newline character:
  // set inital background:
void draw () {
  // everything happens in the serialEvent()

void serialEvent (Serial myPort) {
  // get the ASCII string:
  String inString = myPort.readStringUntil('\n');
  int[] list = int(splitTokens(inString, ","));

  if (inString != null) {
    // trim off any whitespace:
    println( "Recieving:" + inString);
    inString = trim(inString);
    // convert to an int and map to the screen height:
    float inByte = float(list[4]);
    inByte = map(inByte, 0, 1023, 0, height);

    // draw the line:
    stroke(127, 34, 255);
    line(xPos, height, xPos, height - inByte);

    // at the edge of the screen, go back to the beginning:
    if (xPos >= width) {
      xPos = 0;
    } else {
      // increment the horizontal position:

UPDATE: I think this error code was just a bug cause it fixed once I restarted processing + my computer

Sign In or Register to comment.