processing 초보 질문

아두이노와 프로세싱 시리얼 연동 예제인데요
=================
import processing.serial.*;

Serial port; // Create object from Serial class
int val; // Data received from the serial port
int[] values;

void setup()
{
size(640, 480);
// Open the port that the board is connected to and use the same speed (9600 bps)
port = new Serial(this, Serial.list()[1], 9600);
values = new int[width];
smooth();
}

int getY(int val) {
return (int)(val / 1023.0f * height) – 1;
}

void draw()
{
while (port.available() >= 3) {
if (port.read() == 0xff) {
val = (port.read() << 8) | (port.read());
}
}
for (int i=0; i<width-1; i++)
values[i] = values[i+1];
values[width-1] = val;
background(0);
stroke(255);
for (int x=1; x<width; x++) {
line(width-x, height-1-getY(values[x-1]),
width-1-x, height-1-getY(values[x]));
}
}
===========================
아래와 같은 에러가 납니다.

Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
gnu.io.PortInUseException: Unknown Application
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)
at processing.serial.Serial.(Serial.java:139)
at processing.serial.Serial.(Serial.java:105)
at sketch_nov22a.setup(sketch_nov22a.java:54)
at processing.core.PApplet.handleDraw(PApplet.java:1608)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:655)
Exception in thread "Animation Thread" java.lang.RuntimeException: Error inside Serial.()
at processing.serial.Serial.errorMessage(Serial.java:591)
at processing.serial.Serial.(Serial.java:151)
at processing.serial.Serial.(Serial.java:105)
at sketch_nov22a.setup(sketch_nov22a.java:54)
at processing.core.PApplet.handleDraw(PApplet.java:1608)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:655)

Advertisements